posts - 2,  comments - 2,  trackbacks - 0

最近在做一些数据库连接方面的测试的时候,总是会出现各种各样的问题,现将示例代码写出:

import com.mysql.jdbc.*;
import java.sql.*;

   public class TestMySQL
   {
       public static void main(String[] args)
       {
           try
           {
               Class.forName("com.mysql.jdbc.Driver");
               DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            
   
               Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/BookDB?useUnicode=true&characterEncoding=GB2312", "user", "password");
           }
           catch (Exception e)
           {
               System.out.println(e.getMessage());
           }
       }
   }

再将执行后所产生的错误如下:
Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream

** BEGIN NESTED EXCEPTION **

java.io.IOException
MESSAGE: Unexpected end of input stream

STACKTRACE:

java.io.IOException: Unexpected end of input stream
    at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562)
    at com.mysql.jdbc.Connection.<init>(Connection.java:491)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at TestMySQL.main(TestMySQL.java:16)


** END NESTED EXCEPTION **

哪位高手有时间指点一二啊,急啊.不甚感激之至啊.谢谢!

posted @ 2007-04-25 11:30 竹笛月影 阅读(304) | 评论 (0)编辑 收藏

各位好:
      我是一个自学者,在这中间经常遇到一些问题,希望能够得到各位的帮助.
      近来学习通过JDBC与SQL 2000相连接,始终无法得到,具体问题如下:
   
      import java.sql.*;
      import com.microsoft.jdbc.sqlserver.SQLServerDriver;

      public class Test
      {
            public static void main(String[] args)
            {
                  try
                  {
                        Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                        
                        Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=Northwind", "sa", "");

                        .
                        .
                        .
                  }
                  catch (Exception e)
                  {
                  
                  }
         }
      }

       上面是本人的示例代码,示例程序能够正常编译,显示没有任何错误,当执行时却产生如下错误:

         [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

         上面错误始终出现在本人的示例程序中,查阅了Microsoft SQL Server 2000 Driver for JDBC的帮助文档,感觉到本人的示例程序严格按照   
         文档要求来写的,却始终得到这样的错误.
         希望得到各位的帮助.
         不甚感激之至!

         谢谢!

posted @ 2007-04-20 22:49 竹笛月影 阅读(295) | 评论 (2)编辑 收藏

<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(2)

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜