mysql - Exception while dropping database in JavaFX -
private void delete() throws classnotfoundexception, sqlexception { class.forname("com.mysql.jdbc.driver"); connect = drivermanager .getconnection("jdbc:mysql://localhost:3306/delete?" + "user=root&password=virus"); statement = connect.createstatement(); preparedstatement = connect .preparestatement("drop database delete"); preparedstatement.executeupdate(); preparedstatement = connect .preparestatement("create database delete"); preparedstatement.executeupdate(); }
this code delete database in javafx. when ran code gives me exception. details -
com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'delete' @ line 1 @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.util.getinstance(util.java:386) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1053) @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:4120) @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:4052) @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:2503) @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:2664) @ com.mysql.jdbc.connectionimpl.execsql(connectionimpl.java:2794) @ com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement.java:2155) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:2458) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:2375) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:2359) @ deleteaccount.deleteaccount.delete(deleteaccount.java:106) @ deleteaccount.deleteaccount.access$000(deleteaccount.java:26) @ deleteaccount.deleteaccount$1.handle(deleteaccount.java:86) @ deleteaccount.deleteaccount$1.handle(deleteaccount.java:82) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:69) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:217) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:170)
why exception occur ? how can solve ?
Comments
Post a Comment