Java执行sql脚本异常?德比网络服务器
问题描述:
我做了两个类,一个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应用程序作为客户端/服务器体系结构的客户端。如果这可能是一个因素,脚本也很安静吗?Java执行sql脚本异常?德比网络服务器
脚本的顺序如下:
1 - 使架构(细运行没有错误)
2 - 插入SCRIPT1 - 运行正常
2 - 插入SCRIPT2 - 运行良好
3 - 第三脚本返回error.Its不与语法否则会使的是表观
这里是主要方法whic小时,然后经过脚本转换和执行
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 Syntax足够公平,但为什么其他脚本正在执行。
答
三大理念,开始您的诊断:
- 彻底检查客户端异常:http://wiki.apache.org/db-derby/UnwindExceptionChain
- 检查您为您的Derby服务器的derby.log。有时候,错误仅在那里被报告,并且没有被正确地传达给客户。
- 它是否总是t3.sql失败?仔细检查该文件。特别注意奇怪的字符,引号,标点符号等。这些东西会抛出低级解析。
那么唯一的区别是第三个插入脚本包含更多的类型。因此,第一个脚本类似于“插入国家值('阿富汗','AF','亚洲');'和失败的脚本'插入到FLIGHTAVAILABILITY值('AA1211',1,'2004-03-31 ”,2,2,2);'。此外,该网站正在维护中,因此无法看到它 – user2329170 2013-05-02 00:57:35