使用Java连接到.odb数据库 [英] Connecting to a .odb database using java

查看:143
本文介绍了使用Java连接到.odb数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我要提供的帮助是连接带有.odb文件扩展名的数据库

Hey all, All i would like is assistance to connecting to a database with the .odb file extension

//Put this at the beginning  of your program 	
private static final String DATABASE_FILE_NAME = "OfMiceAndMen.mdb"; // this is the usual dbcon system.
private static final String DRIVER = "jdbc:odbc:DRIVER=" + "{Microsoft Access Driver (*.mdb)};" + "DBQ=" + new File (DATABASE_FILE_NAME).getAbsolutePath () + ";";


	static
	{
		try
		{
			Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
		}
		catch (ClassNotFoundException e)
		{
			System.out.println ("Class not found");
			e.printStackTrace ();
		}
	}

	private Connection dbcon 
//put this in the method where you are running your query
dbcon = DriverManager.getConnection (DRIVER);
Statement stmt = dbcon.createStatement ();
String sql = "SELECT Cue, lights, sound, projection, stagedir, ID FROM Cues WHERE ID = " + I + " "; //4
ResultSet rs = stmt.executeQuery (sql);

while (rs.next ())
{
String c = rs.getString ("Cue");// Cue is the name of the column being queried
c = c + "";
}        




这是朋友给的代码..请帮助




This is the code a friend gave.. Pls help

推荐答案



在这里看看:
http://digiassn.blogspot.be/2006/07/java-creating- jdbc-connection-to.html [ ^ ]
Hi,

Have a look here:
http://digiassn.blogspot.be/2006/07/java-creating-jdbc-connection-to.html[^]


这篇关于使用Java连接到.odb数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆