Hi,
ich nochmal^^
Mit einem ActionEvent, welches durch einen Button ausgelöst wird, möchte ich die Gesamte Datenbank entfernen.
Der SQL Befehl hierzu lautet ja : DROP DATABASE MYDATENBANK
Mein Code lautet also wie folgt:
Java kommt hier bis zur Zeile, wo das Statement ausgeführt werden soll. Dann spuckt es mir folgende Fehlermeldung aus:
Die Google Suche hat mich nicht weitergebracht, da alle anderen auch "DROP DATABASE Datenbank" benutzen, um Ihre eigene zu entfernen...
ich nochmal^^
Mit einem ActionEvent, welches durch einen Button ausgelöst wird, möchte ich die Gesamte Datenbank entfernen.
Der SQL Befehl hierzu lautet ja : DROP DATABASE MYDATENBANK
Mein Code lautet also wie folgt:
Code:
//SQL
Statement del;
String sqldel = "DROP DATABASE " + database;
try{
del = conn.createStatement();
del.execute(sqldel);
JOptionPane.showMessageDialog(null, database + " erfolgreich gelöscht.");
}
catch(SQLException | HeadlessException e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null, e);
}
Code:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "DATABASE" at line 1, column 6.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at datenbankgui.Adminpanel.jButton3ActionPerformed(Adminpanel.java:349)
at datenbankgui.Adminpanel.access$100(Adminpanel.java:17)
at datenbankgui.Adminpanel$2.actionPerformed(Adminpanel.java:139)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.sql.SQLException: Syntax error: Encountered "DATABASE" at line 1, column 6.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 47 more
Caused by: ERROR 42X01: Syntax error: Encountered "DATABASE" at line 1, column 6.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
... 41 more
Die Google Suche hat mich nicht weitergebracht, da alle anderen auch "DROP DATABASE Datenbank" benutzen, um Ihre eigene zu entfernen...