Re: semi-colon weirdness when converting from mysql to Oracle



Daisy wrote:
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

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
.



Relevant Pages

  • semi-colon weirdness when converting from mysql to Oracle
    ... but now I'm converting to Oracle. ... but my queries are sensitive to the semi-colon ... the following works for JDBC with mysql and Oracle's SQL ... removing the semi-colon allows the query to work from JDBC ...
    (comp.lang.java.databases)
  • Re: JDBC PreparedStatements, Java Data Objects/O-R mapping, and SQL Injection
    ... "PreparedStatement objects represent SQL statements that can be prepared, ... the MySQL JDBC driver, since it's open source and widely used. ... protection against SQL injection gained by using PreparedStatements, ...
    (SecProg)
  • Re: searching for yoda - a developers tale
    ... added hated IDEs at first, reason being I found they are less ... I also learned SQL first and Java later which resulted in a preference ... I always felt JDBC allows you more control on actual ... > include the JOIN clauseand not have any typos. ...
    (comp.lang.java.programmer)
  • RE: Cannot connect to my SQL 2005 server using JDBC - can any dia
    ... Do you have any references on which version of the Microsoft JDBC driver ... is talking about doesn't talk to UDP 1434 to retrieve the port automatically. ... I have seen some scenarios where not every JDBC drivers handles problems with the UDP broadcast from the SQL Browser service ... Cannot connect to my SQL 2005 server using JDBC - can any diagnostic tool tell me what the problem is? ...
    (microsoft.public.sqlserver.jdbcdriver)
  • RE: BUG: JDBC connection disconnected, cant reconnect
    ... SQL 2005 Standard ... Windows Server 2003, Service Pack 2 ... SQLServer JDBC driver 1.2 ... Sun JDK 1.6 ...
    (microsoft.public.sqlserver.jdbcdriver)