为什么我的Java项目不参见我的JTDS数据库驱动程序
我正在尝试与SQL Server Local数据库连接,我从Intellij级别成功地连接了它,并且有信息需要安装JTDS驱动程序来使用它。我下载了它的最新版本,并从项目中的lib dir中添加为库,尽管Java说它找不到课程,也许我安装了错误?这是我的代码
import java.sql.*;
public class Main {
public static void main(String [] args) throws ClassNotFoundException, SQLException {
Class.forName("net.sourceforge.jtds");
Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://./TPO");
Statement statement = connection.createStatement();
String sqlString = "SELECT * FROM Books";
ResultSet resultSet = statement.executeQuery(sqlString);
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
}
}
}
I'm trying to connect with SQL Server local database, I connected with it successfully from IntelliJ level, and there was information that I need to install jTDS driver to use it. I downloaded latest version of it and added as a library from my lib dir in project, despite this java says that it couldn't find the class, maybe I installed it wrong? Here is my code
import java.sql.*;
public class Main {
public static void main(String [] args) throws ClassNotFoundException, SQLException {
Class.forName("net.sourceforge.jtds");
Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://./TPO");
Statement statement = connection.createStatement();
String sqlString = "SELECT * FROM Books";
ResultSet resultSet = statement.executeQuery(sqlString);
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论