public class TestDB {
public static void main(String[] args) {
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String dbURL =
"jdbc:microsoft:sqlserver://56.1.175.30:1433; DatabaseName=Test ";
String userName = "sa ";
String userPwd = "mygod2004 ";
Connection conn = null; try {
Class.forName(driverName);
conn = DriverManager.getConnection(dbURL, userName, userPwd);
PreparedStatement pstmt = null;
pstmt = conn.prepareStatement( "select* from khzl ");
pstmt.execute();
conn.commit();
System.out.println( "Connection Successful! ");
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (conn != null) {
conn.close();
}
}
catch (SQLException ex) {
}
}
}
} 我的数据库里面有khzl这个表,为什么查询的时候都会报对象名 "khzl "无效阿?我conn = DriverManager.getConnection(dbURL, userName, userPwd);这句都可以执行过去,说明连接没问题阿
public static void main(String[] args) {
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String dbURL =
"jdbc:microsoft:sqlserver://56.1.175.30:1433; DatabaseName=Test ";
String userName = "sa ";
String userPwd = "mygod2004 ";
Connection conn = null; try {
Class.forName(driverName);
conn = DriverManager.getConnection(dbURL, userName, userPwd);
PreparedStatement pstmt = null;
pstmt = conn.prepareStatement( "select* from khzl ");
pstmt.execute();
conn.commit();
System.out.println( "Connection Successful! ");
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (conn != null) {
conn.close();
}
}
catch (SQLException ex) {
}
}
}
} 我的数据库里面有khzl这个表,为什么查询的时候都会报对象名 "khzl "无效阿?我conn = DriverManager.getConnection(dbURL, userName, userPwd);这句都可以执行过去,说明连接没问题阿
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货