JDBC-ODBC连接桥连接数据库的问题

xiaoyuzi xiaoyuzi 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
下面的利用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();
}

}
---------------------------------------------------------
...全文
评论 7
收藏 已收藏
分享
返回顶部
xiaoyuzi
Web 开发 81,108 成员 341,721 内容