Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / December 2006

Tip: Looking for answers? Try searching our database.

semi-colon weirdness when converting from mysql to Oracle

Thread view: 
Daisy - 14 Dec 2006 18:31 GMT
I've used mysql extensively, but now I'm converting to Oracle.  My
inserts are working, but my queries are sensitive to the semi-colon
line termination.  Is there a way to correct this without rewriting all
my queries?

For example, the following works for JDBC with mysql and Oracle's SQL
Command line tool.  But using JDBC with Oracle throws an error:
ORA-00911: invalid character

  SELECT distinct (clientName) FROM tm.ClientSessionInfo;

However, removing the semi-colon allows the query to work from JDBC
with Oracle:

  SELECT distinct (clientName) FROM tm.ClientSessionInfo

I'm using oracle.jdbc.driver.OracleDriver 1.4 and Oracle 10.

The code is:
String query ="SELECT distinct (clientName) FROM tm.ClientSessionInfo;"
statement = connection.prepareStatement( query );
results = statement.executeQuery( );

Do I have to rewrite all my queries without semi-colons or is there
some other solution?  

Thanks
Chris Riesbeck - 14 Dec 2006 18:56 GMT
> I've used mysql extensively, but now I'm converting to Oracle.  My
> inserts are working, but my queries are sensitive to the semi-colon
[quoted text clipped - 11 lines]
>
>    SELECT distinct (clientName) FROM tm.ClientSessionInfo

Remove the semicolons. They should not have been in your SQL strings to
begin with in your JDBC code. They used by command line interfaces but
redundant (or erroneous) in JDBC statements. If you drop them, then the
above queries should work in both systems, and others.

There are however many real incompatibilities between various
implementations of SQL. This is why Hibernate has "dialects" for each
major DBMS. JDBC's escape syntax can help if you want to stick with
straight JDBC.

http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/statement.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.