SQL リーダーと SQL コンパイラーの 2 つのクラスを作成しました。テスト目的で、derby に付属する一連のスクリプト (derbytutor フォルダー) を読み込んで実行しました。私が理解できないのは、特定のエラーが発生せずに実際に実行されるスクリプトが 3 つ以下である理由です。このエラーはA network protocol error was encountered and the connection has been terminated: A PROTOCOL Data Stream Syntax Error was detected. Reason: 0x9,236. Plaintext connection attempt to an SSL enabled server?
、Java アプリケーションをクライアント/サーバー アーキテクチャのクライアントとして実行しているためです。また、それが要因になる可能性がある場合、スクリプトは長く静かです?
スクリプトの順序は次のとおりです。
1 - スキーマを作成します (エラーなしで正常に実行されます)
2 - Script1 を挿入 - 正常に実行
2 - Script2 の挿入 - 正常に実行されます
3 - 3 番目のスクリプトがそのエラーを返します。
スクリプトの変換と実行を実行する主な方法は次のとおりです。
scriptRead scriptBuffer = new scriptRead();
scriptCompiler exec = new scriptCompiler();
try {
final long start = System.currentTimeMillis();
//Load Scripts
String[] schema = scriptBuffer.getScript("schema.sql");
String[] t1 = scriptBuffer.getScript("t1.sql");
String[] t2 = scriptBuffer.getScript("t2.sql");
String[] t3 = scriptBuffer.getScript("t3.sql");
scriptCompiler sc = new scriptCompiler();
//Run scripts
sc.execute(schema);
sc.execute(t1);
sc.execute(t2);
sc.execute(t3);// Problem statement
final long end = System.currentTimeMillis();
long fin = end - start;
System.out.println("Took a time... : " + fin);
}catch(Throwable exc){
System.err.print(exc.getMessage()+"\n");
}
これがスクリプト実行コードです..
public void makeConn() throws SQLException, ClassNotFoundException{
Class.forName(driver);
conn = DriverManager.getConnection(url);
}
@SuppressWarnings("CallToThreadDumpStack")
public void execute(String[] query){
try{
makeConn();
try{
stmt = conn.createStatement();
for(int x = 0; x < query.length;x++){
stmt.execute(query[x]);
}
stmt.close();
closeConn();
}catch(SQLException err){
//err.printStackTrace();
System.err.println(err.getMessage());
}
}catch(Throwable e){
if(e instanceof SQLException){
if(((SQLException)e).equals("08001")){
System.err.println( "Incorrect Username or Password");
}else{
System.err.println( "Check Server is running");
}
}else{
System.err.println("Could not find class path");
}
}
}
問題がどこにあるのか本当にわかりませんか?それがSQL構文で十分だった場合、なぜ他のスクリプトが実行されているのですか。