JSP & MySQL | Error when creating table

Ofir

I'm using Eclipse EE, Tomcat 6 server connected to MySQL server on win7. I was able to connect to a database through JSP and send commands like SELECT and DESCRIBE but if I try to create a table the JSP code will simply not run! Why is that? (Checked my SQL codes on the MySQL command line and it worked. )

JSP error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at

JSP Coding:

try // DB login
    {
        String connectionURL = "jdbc:mysql://localhost/ofir";
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection(connectionURL, "root", "");
        stmt = con.createStatement();
        connected = true;
    }
    catch(Exception ex)
    {
        out.println("Unable to connect to database.");
        connected = false;
    }
    rs = stmt.executeQuery("CREATE table users (fname varchar(50), nname varchar(20), pass varchar(50), email varchar(50), gender boolean, age int(3), region varchar(10), notes varchar(1000))"); // Line of the error

*To be noted about the code- all variables are declared globally using ' <%! '

Mecon

For CREATE TABLE, we have to use stmt.executeUpdate(sql) . Not stmt.executeQuery(sql)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Specific field parameter when creating a table MySQL

From Dev

Syntax error when creating a MySQL trigger

From Dev

MySQL creating table syntax error

From Dev

Creating table 'ShoppingCart' in MySQL - error 1005

From Dev

Adding Index when Creating a Table Error 1064

From Dev

MySQL error #1064 when creating table

From Dev

MySQL table creating error

From Dev

#1604 mysql error when creating a foreign key

From Dev

Error in creating temporary table in mysql

From Dev

Error when creating MySQL Table with PDO

From Dev

SQL Error when creating a table

From Dev

#1089 Error when creating table in phpMyAdmin

From Dev

Error while creating a MySql table

From Dev

mysql error 1064 when creating table. What can I check for?

From Dev

TypeError when creating a MySQL table with parameters

From Dev

error when creating a partitioned table

From Dev

Creating a Collapsible table in JSP

From Dev

Error when creating table with mysqldb module

From Dev

MySQL creating table error

From Dev

MySQL error when creating table with phpmyadmin #1016

From Dev

ERROR 1064 in mysql query for creating table

From Dev

MySQL Error Number 150 when creating Table with Foreign Key

From Dev

Creating a MySQL Table but get error

From Dev

ERROR 1064 (42000) creating table in mysql

From Dev

Error 1604 while creating table MySQL

From Dev

TypeError when creating a MySQL table with parameters

From Dev

Error creating mysql table with Foreign Key

From Dev

error when creating table in hive

From Dev

Error when creating a pivot table using VBA