JDBC-ODBC连接桥连接数据库的问题
下面的利用JDBC-ODBC连接桥连接数据库有什么错?
提示错误:Exception in thread "main" java.lang.NoClassDefFoundError:TestDataSource
-------------------TestDataSource.java----------------------
import java.sql.*;
public class TestDataSource
{
public TestDataSource()
{
}
public void connectAndDisconnect()
{
try
{
System.out.println("Attempting to load the JDBC Driver ...");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("JDBC driver loaded.");
System.out.println("Connecting to database...");
Connection con;
con = DriverManager.getConnection("jdbc:odbc:bookmarks");
System.out.println("Database connection established.");
System.out.println("Database connection closed");
if (con!=null)
{
con.close();
}
System.out.println("Database connection closed.");
}
catch(ClassNotFoundException cnfe)
{
System.out.println("ClassNotFoundException:could not locate DB driver");
}
catch(SQLException cnfe)
{
System.out.println("SQLException:Database reports an error.");
}
catch(Exception e)
{
System.out.println("An unknown error occurred while connecting to DB.");
}
}
public static void main(String args[])
{
TestDataSource test=new TestDataSource();
test.connectAndDisconnect();
}
}
---------------------------------------------------------