Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to execute a simple CREATE TABLE query on an oracle10g database using java. This is what I am doing:

Connection conn = //create connection
//open connection.  No errors/warnings are generated so I assume this succeeds 
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("CREATE TABLE t1 (c1 INTEGER NOT NULL, c2 VARCHAR(100), c3 INTEGER NULL, CONSTRAINT m_pk PRIMARY KEY (c1));");
//close connection.  No errors again so I assume it succeeds.

When I execute the command (copying and pasting into terminal window) directly on the command line, it succeeds. When I run the above java code, this is the error I get:

java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

I dont understand how I could have an invalid character since copying and pasting it into terminal works perfectly fine.

share|improve this question

closed as too localized by Phil, Marian, Paul White, RolandoMySQLDBA, StanleyJohns Apr 21 '13 at 14:14

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

Nevermind. I jumped the gun on posting here! When executing queries in java, I am not suppose to put the semi-colon at the end of the statement. I had tried not putting the semi-colon at the end and it ran without errors but I thought I had checked my database and saw that no table was created. I have now confirmed that dropping the semi-colon has worked!

share|improve this answer
If it solved your problem, then mark it as the answer, so we don't have the question hanging ;). – Marian Apr 21 '13 at 9:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.