Click here to Skip to main content
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
Umar2291

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 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


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