JDBC ODBC Bridge
In this chapter you will learn:
Connect with ODBC
The following code shows how to make a connection to Access database using JDBC ODBC driver.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
//j a v a2s . c o m
public class Main {
public static void main(String args[]) throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String URL = "jdbc:odbc:dbName";
Connection dbConn = DriverManager.getConnection(URL, "user", "pass");
dbConn.close();
PreparedStatement prepstmt;
prepstmt = dbConn.prepareStatement("SELECT id FROM employee");
prepstmt.execute();
prepstmt.close();
dbConn.close();
}
}
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » Driver and Connection