我做了两个类,一个 SQL 阅读器和一个 SQL 编译器。出于测试目的,我读入并执行了 derby 附带的一组脚本,即 derbytutor 文件夹。我无法弄清楚为什么实际上执行的脚本不超过三个而没有发生特定错误。这个错误是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 - 第三个脚本返回该错误。它不是语法,否则它会很明显
这是贯穿脚本转换和执行的主要方法
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 语法足够公平,那么为什么要执行其他脚本。