Click here to Skip to main content
13,091,300 members (52,139 online)
Rate this:
Please Sign up or sign in to vote.
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 () + ";";

			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 ( ())
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
Posted 8-Oct-12 4:20am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Umar2 8-Oct-12 12:56pm
It still doesn't work, the "JDBCDriver cannot be resolved to a type".. Thats what it said in Eclipse
ProgramFOX 8-Oct-12 13:03pm
Try it with jdbcDriver instead of JDBCDriver.
Umar2 8-Oct-12 14:28pm
Same result, the "import org.hsqldb.jdbcDriver;" cannot be resolved.. Thats what eclipse returned

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100