누구나 다음 연결에 어떤 문제가 있는지 말해 줄 수 있습니까? 데이터베이스에 레코드를 삽입하려하고 있습니다. 몇 가지 이유 때문에 시도 할 때마다 다음 두 가지를 계속 인쇄합니다. 내 프로그램을 실행하려면 :쿼리 문자열 길이 만 출력
Stacktrace below:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '14:55:32 , SimpleX Error Notification, Error Simple X Queue, No Troubleshoo' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2819)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725)
at mypackagename.Myclassreader.call(Myclassreader.java:492)
at mypackagename.Myclassreader.call(Myclassreader.java:25)
: 여기
Statement InsertRemoteResultsErrorLogStmt = null;
ResultSet SelectErrorLogRS = null;
Connection connRemoteforCatch = null;
try {
String QueryStringInsertIntoErrorLogs = "";
connRemoteforCatch = DriverManager.getConnection("jdbc:mysql://xx.xx.x.xxx:3306/test", MainUser, MainPass);
QueryStringInsertIntoErrorLogs = " INSERT INTO simplequeue.errorlogs "
+ " ("
+ " ErrorNumber_int, "
+ " Created_dt, "
+ " Subject_vch, "
+ " Message_vch, "
+ " TroubleshootingTips_vch, "
+ " CatchType_vch, "
+ " CatchMessage_vch, "
+ " CatchDetail_vch, "
+ " Host_vch, "
+ " Referer_vch, "
+ " UserAgent_vch, "
+ " Path_vch, "
+ " Querystring_vch "
+ ") "
+ " VALUES "
+ " ("
//+ " NULL, " // ErrorLogIdInt
+ " 2002 , " // ErrorNumber_int
+ " 2014-03-12 14:55:32 , "
+ " SimpleX Error Notification, "
+ " Error Simple X Queue, "
+ " No Troubleshooting Tips Specified, "
+ " testgetsqlstate , "
+ " testgetmessage ,"
+ " NULL, "
+ " ebmdevii.messagebroadcast.com,"
+ " NULL, "
+ " CFSCHEDULE, "
+ " NULL, "
+ " DBSOURCE=BishopDev, "
+ ") ";
System.out.println("the length of the Query String for Error is :" + QueryStringInsertIntoErrorLogs.length());
InsertRemoteResultsErrorLogStmt = connRemoteforCatch.createStatement();
InsertRemoteResultsErrorLogStmt.executeUpdate(QueryStringInsertIntoErrorLogs);
} catch (SQLException ex1) {
System.out.println("Stacktrace below:");
ex1.printStackTrace();
System.out.println("Value of Catch inside Catch with SQLException ex1:" + connRemoteforCatch.isValid(2));
}
내 스택 트레이스입니다 다음과 같이
the length of the Query String for Error is :506
Value of Catch inside Catch with SQLException ex1:true
내 코드입니다
첫 줄에 SQL 구문 오류가 있지만, 동일한 SQL 쿼리를 MySQL Workbench에서 사용하고 성공적으로 레코드를 삽입했습니다. 그리고 Java 프로그램에서 구문 오류가없는 것 같습니다.
Stacktrace below:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Error Notification, Error Simple X Queue, No Troubleshooting Tips Specified, ' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
최근 스택 트레이스 :
업데이트 스택 트레이스를 알려 주시기 바랍니다
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2819)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725)
at ebmextractor.Myclassreader.call(Myclassreader.java:493)
at ebmextractor.Myclassreader.call(Myclassreader.java:25)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1259)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
주석 처리 대신 스택 추적을 추가하면 문제가 무엇인지 알 수 있습니다. 인쇄 줄을 주석 처리하고 스택 추적의 주석을 제거하고 결과를 게시하십시오. – Acapulco
스택 트레이스를 보여줄 수 있습니까? uncomment'ex1.printStackTrace(); ' – Incognito
['Connection # isValid'] (http://docs.oracle.com/javase/7/docs/api/java/sql/Connection)에서이 문서를 읽어야한다고 생각합니다. .html # isValid (int)) 이것이 당신에게 무엇을 말하고 있는지 이해할 수 있습니다. – MadProgrammer