Click here to Skip to main content
11,720,545 members (80,671 online)
Rate this: bad
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 at 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 at 8-Oct-12 13:03pm
Try it with jdbcDriver instead of JDBCDriver.
Umar2 at 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
0 Sergey Alexandrovich Kryukov 2,129
1 OriginalGriff 884
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540

Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2015
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