Exception in thread "main" java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 're talking election 2016 with @ForbesOpinion's @Avik ' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createBatchUpdateException(SQLError.java:1161)
at com.mysql.jdbc.StatementImpl.executeBatchInternal(StatementImpl.java:1048)
at com.mysql.jdbc.StatementImpl.executeBatch(StatementImpl.java:958)
at FirstTwitterApp.main(FirstTwitterApp.java:76)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 're talking election 2016 with @ForbesOpinion's @Avik ' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:942)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)
at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1540)
at com.mysql.jdbc.StatementImpl.executeBatchInternal(StatementImpl.java:1022)
... 2 more
Der Code:BatchUpdateException während diese Abfrage mit Twitter4J Ausführung
Date your_date = tweet.getCreatedAt() ;
SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM-dd h:m:s");
String date = formatter.format(your_date);
String textStatus = tweet.getText();
System.out.println(textStatus);
String qry="insert into twitter_data(id,name,text_status,profile_picture,created_date)values(NULL,'"
+tweet.getUser().getScreenName()+"','"
+textStatus+"','"+tweet.getUser().getOriginalProfileImageURL()+"','"
+date+"')";
connect.st.addBatch(qry);
connect.st.executeBatch();
Datum your_date = tweet.getCreatedAt(); \t \t \t \t \t \t Simple Formatter = new Simpledate ("YYYY-MM-DD h: m: s"); \t \t \t \t \t \t Zeichenfolge date = formatter.format (your_date); \t \t \t \t \t \t Zeichenfolge textStatus = tweet.getText(); \t \t \t \t \t \t System.out.println (TextStatus); \t \t \t \t \t \t String qry = "insert in twitter_data (id, name, text_status, profile_picture, created_date) Werte (NULL, ' "+ tweet.getUser(). GetScreenName() +"'," "+ textStatus +" ',' "+ tweet.getUser(). getOriginalProfileImageURL() + '', '" + date +' ') "; \t \t \t \t \t \t \t connect.st.addBatch (qry); connect.st.executeBatch(); – user3528272
Sie könnten lesen, was eine SQL-Injection-Schwachstelle ist; Verwenden Sie dann eine PreparedStatement-Anweisung, anstatt Ihre SQL-Abfrage als Zeichenfolge zu erstellen. –