472,106 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,106 software developers and data experts.

Cannot create view using jdbc

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
3 5065

"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
"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

"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.

Similar topics

2 posts views Thread by sea | last post: by
3 posts views Thread by r_stringer66 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.