When you create an SQL statement in JDBC you should not include the
semicolon at the end of the line. Also the apostrophe in "Natasha's" may be
giving you problems. You may need to remove it or use \' or something like
that.
-----Original Message-----
From: Raymond Camden [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 16, 2001 12:42 PM
To: JRun-Talk
Subject: Going crazy w/ something the should work, SQL + Java problem
I've been playing with Java and ODBC for a few days now and I've run into a
brickwall with something. I have an app that reads in a text file, parses
it, and creates a SQL statement out it. I've hard coded the columns and I
know the line format, so it's really just a "one time deal" type script, but
something is going wrong. For some reason this string is giving me a SQL
error.
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL
Server]Unclosed quotation mark before the character string 'eng'.
insert into
tblMp3s(Filename,Version,Title,Artist,Album,YearReleased,Comment,Track,Genre
) values('f:\music\sleeping_jesus.mp3','2','Sleeping Jesus','Natasha''s
ghost','Everything Under The Moon',1999,'eng
http://mp3.com/NatashasGhost',0,'');
As far as I can tell this is valid SQL. I even cut and pasted into CF and it
worked fine. Any clues as to why this would work in CF but fail in Java?
(Here is a snippet of the code running the statement: (statements is a
Vector of insert statements)
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:odbc:MP3Music;UID=sa;PWD=");
Statement stmt = con.createStatement();
for(int i = 0; i < statements.size(); i++) {
String statement = (String)statements.get(i);
try {
int x = stmt.executeUpdate(statement);
} catch (Exception e) {
System.out.println(e);
System.out.println(statement);
}
}
con.close();
} catch (Exception e) {
System.out.println(e);
System.out.println(temp);
}
=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia
Email : [EMAIL PROTECTED]
ICQ UIN : 3679482
"My ally is the Force, and a powerful ally it is." - Yoda
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists