Hello all,
I am using Tomcat 5.0.9 and Mysql 4-0-14 which are running on a Sun/Solaris server. I have had both up and running for quite some time. I use databases to store information that is extracted to dynamically create a web app. To store/update/extract the information contained in these databases, there is an administration tool which serves this role. On one of the JSPs there is a form to create a new database which sends relevant data to a bean which handles the connections.
To create a new database, I use JDBC to connect to a dummy database. The following code is what I use to do so:
Connection connect =
DriverManager.getConnection("jdbc:mysql:///"
+ "dummy" + "?user=" + userName +
"&password=" + password);
Statement stmt = connect.createStatement();
String create = new String( "create database " +
databaseName );
stmt.execute( create );
stmt.close();
/* try connecting to the new database */
connect = DriverManager.getConnection("jdbc:mysql:///"
+ databaseName + "?user=" + userName +
"&password=" + password);
stmt = connect.createStatement();
/* create an empty database */
String script = new String(
"source/home/webapps/mysql/scripts/createTables.sql" );
boolean check = stmt.execute( script );
When the user requests a new database, error messages are displayed at the bottom of the page, and I get
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'source /home/webapps/mysql/scripts/createTables.sql' at line 1"
I know that there are no errors in the script, because I can use mysql -u root -p -D <<databaseName>> to connect
and source the script and everything works fine.
Any ideas would be greatly appreciated.
Thanks.