473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 5157

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David | last post by:
Hello all, I have been trying to use the OCI driver to connect to Oracle 9i, but have been getting the following error: java.sql.SQLException: Closed Connection at...
0
by: Corrine | last post by:
Why am I getting this exception, and how can I fix it? I took out all the commit's and "select ... for update" statements that I had been calling using JDBC, but I'm still getting this exception. I...
2
by: sea | last post by:
I have DB2 UDB Workgroup version 7.2 -- the JDBC-ODBC bridge loads perfectly fine but when I try to use JDBC I get an error, copying and pasting below. I added db2java.zip and db2jdbc.dll to both...
3
by: r_stringer66 | last post by:
Hi, I am trying to connect to a db2 database via a jdbc application and this is the following error I get: Exception : CLI0615E Error receiving from socket, server is not responding....
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
1
by: rpm45tech | last post by:
Hi everyone. I'm deveolping in Java with DB2 running on Win XP and everything was working ok but then I installed Vista Ultimate and the application stopped working. This is the exception showed: ...
0
by: diane | last post by:
Just trying to upsize using VFP 9 with SQL 2005 using VFP remote views. One in particular keeps coming up and saying Cannot insert the value NULL into column, when I really don't think I am...
2
by: dvawdrey | last post by:
Can someone help me please with the following code: try { DatabaseMetaData metadata=con.getMetaData(); System.out.println(metadata.getDriverName()); System.out.println("Driver version:...
0
by: thesti | last post by:
hello, i'm trying to connect to SQL Server 2000 on my localhost through JDBC. i'm using the Microsoft SQL Server JDBC Driver 2.0 i couldnt make it, as i get the following error Unable to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.