?
Solved

Creating Schema In JAVA for MySQL

Posted on 2007-07-22
8
Medium Priority
?
386 Views
Last Modified: 2008-01-09
I want to create a schema from my JAVA code. I am using Connector MX/J(Portable) drivers.
My code looks like

DriverManager.getConnection("jdbc:mysql://localhost:port/db",userName,password)
Here what should be the db name??
0
Comment
Question by:sangameshrh
  • 3
  • 3
  • 2
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 19545328
try mysql
0
 

Author Comment

by:sangameshrh
ID: 19545341
Sorry. I am using mysql
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 19545353
> Here what should be the db name??
Name of the schema. Can be blank also.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 19545362
> Sorry. I am using mysql

i know, i meant use that for the database name.

DriverManager.getConnection("jdbc:mysql://localhost:port/mysql",userName,password)
0
 

Author Comment

by:sangameshrh
ID: 19545452
I changed it to mysql. But when I try to execute with the query "CREATE SCHEMA exchang" I am getting this exception

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your S
QL syntax; check the manual that corresponds to your MySQL server version for th
e right syntax to use near 'SCHEMA xchange' at line 1
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:3243)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:3172)
        at com.mysql.jdbc.Statement.execute(Statement.java:706)
        at test.MYSQLConnector.executeQuery(MYSQLConnector.java:46)
        at test.CreateDB.<init>(CreateDB.java:11)
        at test.CreateDB.main(CreateDB.java:34)
[MysqldResource] stopping mysqld (process: 4076)
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 19545470
try: "create database exchange"
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 19545475
You should use "create database exchang"

more: http://dev.mysql.com/doc/refman/5.0/en/create-database.html
0
 

Author Comment

by:sangameshrh
ID: 19545495
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question