Click here to Skip to main content
12,401,324 members (39,687 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 () + ";";
 

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

1 solution

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

Solution 1

  Permalink  
Comments
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 | Mobile
Web02 | 2.8.160721.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2016
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