bob

bob's

置顶随笔

[置顶]求助:SQL2000cONNECTION

 1import java.sql.*;
 2public class TestSql2000Connection {
 3    
 4    
 5    public static void main(String[] args) {
 6        Connection conn=null;
 7        Statement stmt=null;
 8        ResultSet rs=null;
 9        try {
10            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
11            conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/college1?user=sa&password=643208225&useUnicode=true&characterEncoding=UTF-8");
12            stmt=conn.createStatement();
13            rs=stmt.executeQuery("Select * from dept");
14            while (rs.next()) {
15                System.out.println(rs.getString("deptNo")+" "+rs.getString("deptName"));
16            }

17        }
 catch (ClassNotFoundException e) {
18            // TODO: handle exception
19            e.printStackTrace();
20        }
catch(SQLException ex){
21            ex.printStackTrace();
22        }

23    }

24
25}

26

结果编译出现这种错误:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect.  Invalid URL.
 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
 at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
 at java.sql.DriverManager.getConnection(DriverManager.java:525)
 at java.sql.DriverManager.getConnection(DriverManager.java:193)
 at TestSql2000Connection.main(TestSql2000Connection.java:11)

posted @ 2008-09-26 14:41 陈章波 阅读(132) | 评论 (0)编辑 收藏

2008年9月26日

求助:SQL2000cONNECTION

 1import java.sql.*;
 2public class TestSql2000Connection {
 3    
 4    
 5    public static void main(String[] args) {
 6        Connection conn=null;
 7        Statement stmt=null;
 8        ResultSet rs=null;
 9        try {
10            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
11            conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/college1?user=sa&password=643208225&useUnicode=true&characterEncoding=UTF-8");
12            stmt=conn.createStatement();
13            rs=stmt.executeQuery("Select * from dept");
14            while (rs.next()) {
15                System.out.println(rs.getString("deptNo")+" "+rs.getString("deptName"));
16            }

17        }
 catch (ClassNotFoundException e) {
18            // TODO: handle exception
19            e.printStackTrace();
20        }
catch(SQLException ex){
21            ex.printStackTrace();
22        }

23    }

24
25}

26

结果编译出现这种错误:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect.  Invalid URL.
 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
 at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
 at java.sql.DriverManager.getConnection(DriverManager.java:525)
 at java.sql.DriverManager.getConnection(DriverManager.java:193)
 at TestSql2000Connection.main(TestSql2000Connection.java:11)

posted @ 2008-09-26 14:41 陈章波 阅读(132) | 评论 (0)编辑 收藏

仅列出标题  
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

导航

统计

常用链接

留言簿(1)

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜