2016-08-03 11 views
0

"ネットワークからの読み取り中にデータが不十分です - 最低6バイトが必要で、0バイトしか受信しませんでした。私のデータベースに接続しようとすると。私は動作する解決策を見つけることができないようです。あなたは私に手を差し伸べることができますか?ここでJava SQLは6バイトを予期し、0エラーを受け取りました

import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 

public class RetrieveData 
{ 
    private String zone; 
    private String date; 
    private String userName = "User"; 
    private String password = "Password"; 
    private String serverAdress= "jdbc:derby://Server:1010/Database"; 
    private Connection con = null; 
    private Statement stmt = null; 
    private ResultSet rs = null; 
    RetrieveData(String zoneToPull, String dayToPull) 
    { 
     zone = zoneToPull; 
     date = dayToPull; 
    } 

    public int HistoryActual() 
    { 
     try 
     { 
      Class.forName("org.apache.derby.jdbc.ClientDriver"); 
      con = DriverManager.getConnection(serverAdress, userName, password); 
      String sql = "SELECT TOP 10 " + 
           "*" + 
          "FROM" + 
           "walks" + 
          "WHERE"+ 
           "company_id = 'TMS3'"; 
      stmt = con.createStatement(); 
      rs = stmt.executeQuery(sql); 
      while (rs.next()) 
      { 
       System.out.println(rs.getString(4) + " " + rs.getString(6)); 
      } 
     } 
     catch (SQLException e) 
     { 
      System.out.println(e.getMessage()); 
     } 
     finally 
     { 
      if (rs != null) try { rs.close(); } catch(Exception e) {} 
      if (stmt != null) try { stmt.close(); } catch(Exception e) {} 
      if (con != null) try { con.close(); } catch(Exception e) {} 
     } 
     return 0; 
    } 
} 

は、スタックトレースです:

java.sql.SQLNonTransientConnectionException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 0 bytes. The connection has been terminated. at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at RetrieveData.HistoryActual(RetrieveData.java:27) at BookToGoals.(BookToGoals.java:34) at Console.Console(Console.java:96) at Console.access$0(Console.java:47) at Console$1.run(Console.java:43) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: ERROR 08006: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 0 bytes. The connection has been terminated. at org.apache.derby.client.net.Reply.fill(Unknown Source) at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source) at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source) at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source) at org.apache.derby.client.net.NetConnectionReply.readExchangeServerAttributes(Unknown Source) at org.apache.derby.client.net.NetConnection.readServerAttributesAndKeyExchange(Unknown Source) at org.apache.derby.client.net.NetConnection.flowServerAttributesAndKeyExchange(Unknown Source) at org.apache.derby.client.net.NetConnection.flowUSRIDPWDconnect(Unknown Source) at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source) at org.apache.derby.client.net.NetConnection.(Unknown Source) at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl.newNetConnection(Unknown Source) ... 22 more

+0

質問の一部としてスタックトレースを追加できますか? – JavaHopper

+0

Derbyデータベースの設定方法についても説明します。これは、使用している処理中のファイルベースのデータベースですか、それともderbyデータベースを実行している別のプロセスですか? – user3745362

+0

データベースは別のサーバーで実行されています。主な用途は別のプログラムです。私はちょうどそれからデータを取得しようとしています。 – Ardel

答えて

0

私は何が起こっているかが分かったように見えます。それは私自身の混乱によるものです。私はMicrosoft SQLデータベースに接続しようとしています。したがって、私はderbyではないsqljdbcドライバが必要です。これは私の問題を解決しました。助けてくれてありがとう。

関連する問題