Click here to Skip to main content
11,478,174 members (70,873 online)
Rate this: bad
good
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 5:20am
Umar2192

1 solution

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

Solution 1

  Permalink  
Comments
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 Frankie-C 160
1 Sergey Alexandrovich Kryukov 149
2 Sascha Lefèvre 145
3 F-ES Sitecore 130
4 siddartha kopparapu 103
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,321
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,325


Advertise | Privacy | Mobile
Web03 | 2.8.150520.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