import java.sql.Connection;
import java.sql.DriverManager;
class OdbcConnection
{
static public Connection getConnection()
{
try
{//temp.mdb是自己建立的数据库
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};" +
"DBQ=temp.mdb");
return conn;
}
catch(java.lang.ClassNotFoundException e)
{
System.out.print("get Connection error!");
System.out.print(e);
}
catch(java.sql.SQLException ee)
{
System.out.print("get connection error");
System.out.print(ee);
}
return null;
}
}