# Fehlermeldung beim Erstellen einer neuen Tabelle



## Pennywise (29. Jun 2005)

Hi, schaff es einfach nich ne neue Tabelle zu erstellen.

Hier mein Quellcode + Fehlermeldung:


```
public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        String sql = "CREATE TABLE ? (Name CHAR(30), FIRMA CHAR(20), Preis CHAR(10), Katalog CHAR(30))";
	    try {
	        if(stm == null) {
	            stm = connection.prepareStatement(sql);
	            stm.setString(1, fieldArtikelGruppe.getText());
		        stm.execute();
		        stm.getConnection().commit();
	        }  
	    }
	    catch(Exception exc) {
	        exc.printStackTrace();
	    }   
}
```


java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Unzulässige SQL-Anweisung; 'DELETE', 'INSERT', 'SELECT' oder 'UPDATE' erwartet.
	at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
	at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
	at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3104)
	at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:214)
	at de.loeffler.db.ArtgGruppeAnl.actionPerformed(ArtgGruppeAnl.java:90)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
	at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
	at java.awt.Component.processMouseEvent(Component.java:5134)
	at java.awt.Component.processEvent(Component.java:4931)
	at java.awt.Container.processEvent(Container.java:1566)
	at java.awt.Component.dispatchEventImpl(Component.java:3639)
	at java.awt.Container.dispatchEventImpl(Container.java:1623)
	at java.awt.Component.dispatchEvent(Component.java:3480)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
	at java.awt.Container.dispatchEventImpl(Container.java:1609)
	at java.awt.Window.dispatchEventImpl(Window.java:1590)
	at java.awt.Component.dispatchEvent(Component.java:3480)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)


Connection wird auf jeden Fall aufgebaut, das hab ich überprüft.

Danke im Voraus.


----------



## P3AC3MAK3R (29. Jun 2005)

Lehne Dich doch mal an dieses Beispiel an:

http://javaalmanac.com/egs/java.sql/CreateBasicTable.html


----------



## Pennywise (29. Jun 2005)

Alles klar. habs selbst gerade geklärt.
Natürlich falsch, wenn ich den Tabellennamen mit ? vergeben will.

Trotzdem Danke für die Hilfe.


----------

