473,671 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot create view using jdbc

Hello,
I thought I knew sql, but when I send this as an argument of a
Statement.execu te():

create view mike.unnamed1(W ORKDEPT) 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(W ORKDEPT) 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.jd bc.net.DB2Drive r)

Has anybody seen/dealt with this?
Any hints would be much appreciated.
Nov 12 '05 #1
3 5175

"Mike Schuler" <ma*****@imag.n et> wrote in message
news:27******** *************** ***@posting.goo gle.com...
Hello,
I thought I knew sql, but when I send this as an argument of a
Statement.execu te():

create view mike.unnamed1(W ORKDEPT) 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(W ORKDEPT) 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.jd bc.net.DB2Drive r)

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.jdb c.app.DB2Driver ; I assume it will also work for the 'net'
driver.

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

Statement stmt02 = conn01.createSt atement();

stmt02.executeU pdate(createStm t);

}

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.e ye-bee-em.com> wrote in message
news:41******** @news3.prserv.n et...
"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
17868
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 oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2364) at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:480)
0
9397
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 even tried to setAutoCommit(false) but that didn't help. :( java.io.IOException: ORA-22990: LOB locators cannot span transactions at oracle.jdbc.driver.DatabaseError.SQLToIOException(DatabaseError.java) at...
2
11681
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 the classpath and path variables, still no luck. Anyone have any ideas please? Thank you very much! java.lang.ClassNotFoundException: COM.ibm.db2.jdbc.app.DB2Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
3
13371
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. SQLSTATE=08S01 Below is the following code I am using. I did not specify the port number but even when I try specify it I get the same error.
9
3550
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 'Syntax error in CREATE TABLE statement' even though I am not creating a table, but a Database // - - - - - - - - - - - - sun.jdbc.odbc.JdbcOdbc aSQL=CREATE DATABASE dbtest; java.sql.SQLException:
1
8786
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: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'COM.ibm.db2.jdbc.app.DB2Driver' for connect URL...
0
2077
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 inserting a NULL value. Oddly sometimes it works but I don't know why. Can anyone suggest anything else I can try? Perhaps this is the wrong group I'm posting to - it was just the one that came up with other errors giving the same message, but none of...
2
8620
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: " +metadata.getDriverVersion()); System.out.print("JDBC version: " + metadata.getJDBCMajorVersion()); System.out.println("." +metadata.getJDBCMinorVersion());
0
3762
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 add connection. Cannot establish a connection to jdbc:sqlserver://localhost:1433;databaseName=Northwind using com.microsoft.sqlserver.jdbc.SQLServerDriver (The TCP/IP connection
0
8481
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8400
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6234
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.