By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,018 Members | 930 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,018 IT Pros & Developers. It's quick & easy.

Cannot create view using jdbc

P: n/a
Hello,
I thought I knew sql, but when I send this as an argument of a
Statement.execute():

create view mike.unnamed1(WORKDEPT) as select f1.WORKDEPT as
\"WORKDEPT\"\r\nfrom MIKE.EMPLOYEE f1\r\nfor read only\r\n

I get:

[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token \"create view
mike.unnamed1(WORKDEPT) as sel\" was found following
\"BEGIN-OF-STATEMENT\". Expected tokens may include: \"<values>\".
SQLSTATE=42601\r\n

Since this code works for Sybase, Oracle, Cache, SQLServer, Postgress,
etc. I have to assume this is a JDBC driver fault.
(COM.ibm.db2.jdbc.net.DB2Driver)

Has anybody seen/dealt with this?
Any hints would be much appreciated.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Mike Schuler" <ma*****@imag.net> wrote in message
news:27**************************@posting.google.c om...
Hello,
I thought I knew sql, but when I send this as an argument of a
Statement.execute():

create view mike.unnamed1(WORKDEPT) as select f1.WORKDEPT as
\"WORKDEPT\"\r\nfrom MIKE.EMPLOYEE f1\r\nfor read only\r\n

I get:

[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token \"create view
mike.unnamed1(WORKDEPT) as sel\" was found following
\"BEGIN-OF-STATEMENT\". Expected tokens may include: \"<values>\".
SQLSTATE=42601\r\n

Since this code works for Sybase, Oracle, Cache, SQLServer, Postgress,
etc. I have to assume this is a JDBC driver fault.
(COM.ibm.db2.jdbc.net.DB2Driver)

Has anybody seen/dealt with this?
Any hints would be much appreciated.


Try using executeUpdate() instead of execute().

This is some code I have that works fine on DB2 for Windows/Linux/Unix with
COM.ibm.db2.jdbc.app.DB2Driver; I assume it will also work for the 'net'
driver.

String createStmt = "create view ..."; //your 'Create View' statement
try {

Statement stmt02 = conn01.createStatement();

stmt02.executeUpdate(createStmt);

}

catch (SQLException excp) {

//your error handling logic

}

Rhino
Nov 12 '05 #2

P: n/a
"FOR READ ONLY"? DB2 does not support this syntax outside of the
select-statement.
I'm curious whether your driver strips it for other DBMS or whether
other DBMS indeed support this syntax natively to define READONLY views (?).
... easy enough to support if it's a common problem.

Cheers
Serge
Nov 12 '05 #3

P: n/a

"Serge Rielau" <sr*****@ca.eye-bee-em.com> wrote in message
news:41********@news3.prserv.net...
"FOR READ ONLY"? DB2 does not support this syntax outside of the
select-statement.
I'm curious whether your driver strips it for other DBMS or whether
other DBMS indeed support this syntax natively to define READONLY views (?). .. easy enough to support if it's a common problem.

Good point, Serge! I had forgotten that FOR READ ONLY isn't allowed in a
CREATE VIEW. Perhaps that is part of the problem.

Rhino
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.