Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

closed as too localized by FreshPhilOfSO, 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.

1 Answer

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
add comment

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