赞
踩
有无大神可以解答,已经在sql server配置管理器中打开TCP/IP,也设置了端口1433,配置完之后也重启了SQL Server,但是在eclipse中一运行就报错,实在看不懂了。求解答(报错图片在下面)
以下是代码
- package db;
- import java.sql.*;
- public class db {
- private Connection dbConn;
- private Statement stateMent;
- public db() {
- String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
- String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=pay0101";
- String userName="sa";//默认用户名
- String usePwd="******";//密码
- try {
- Class.forName(driverName);
- dbConn=DriverManager.getConnection(dbURL, userName, usePwd);
- System.out.println("Connection Successful!");
- }catch(Exception e) {
- System.out.println(e.getMessage());
- }
- }
- public int executeUpdate(String sql) throws SQLException{
- stateMent=dbConn.createStatement();
- return stateMent.executeUpdate(sql);
- }
- public ResultSet executeQuery(String sql) throws SQLException{
- stateMent=dbConn.createStatement();
- return stateMent.executeQuery(sql);
- }
- public void closeConn() throws SQLException{
- stateMent.close();
- dbConn.close();
- }
-
-
- }
TCP/IP
连接时报错
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。