How to "CREATE VIEW" by using JDBC? Thanks.

How to "CREATE VIEW" by using JDBC? Thanks.
[57 byte] By [jw2001] at [2007-9-26 1:52:51]
# 1
The following creates the view test1 from table testStatement s = sconn.createStatement();String createview = "CREATE VIEW test1 AS SELECT * FROM test";s.executeUpdate(createview); Jamie
jlrober at 2007-6-29 3:03:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Thanks.

My code is as below:

Statement Stmt = Conn.createStatement();

Stmt.executeUpdate("CREATE VIEW csclass AS SELECT SID FROM CSGRADE10");

But when ran it, I encounter an error:

SQLException: Error during query: Unexpected Exception: java.sql.SQLException me

ssage given: Syntax error or access violation: You have an error in your SQL syn

tax near 'VIEW csclass AS SELECT SID FROM CSGRADE10' at line 1

SQLState:S1000

VendorError: 0

What's the problem?

Thank you.

jw2001 at 2007-6-29 3:03:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
can you successfully execute the statement in a SQL*Plus session or similar environment? If yes, then does your user have sufficient priveleges/permissions? Try those first, let me know what happens. What type of database are you running with your program?Jamie
jlrober at 2007-6-29 3:03:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Hi Jamie:

Thank you for your help.

Could you please tell me what is "SQL*Plus session"?

I modified the code into:

Statement Stmt = Conn.createStatement();

Stmt.executeUpdate("CREATE VIEW csclass AS SELECT * FROM CSGRADE10");

The error message is the same:

SQLException: Error during query: Unexpected Exception: java.sql.SQLException message given: Syntax error or access violation: You have an error in your SQL syntax near 'VIEW csclass AS SELECT * FROM CSGRADE10' at line 1

SQLState:S1000

VendorError: 0

I am using MySQL.

Jack

jw2001 at 2007-6-29 3:03:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...