I'm connecting to a SQL Server 7 database, with table Customer with a field
called Company. One of the records contains has the field "Microsoft" in it.
I'm using JDBC-ODBC Bridge.
// I cannot do the following
// (At this point Connection "con" is established and OK)
// All wrapped up in appropriate try/catch statements...
String SQL = "SELECT * FROM Customer WHERE Company LIKE ?";
PreparedStatement ps = con.prepareStatement(SQL);
ps.setString(1, "Microsoft");
ResultSet rs = ps.executeQuery(); // RETURNS AN EMPTY SET
// ----------------------------------------
// This however works
String SQL2 = "SELECT * FROM Customer WHERE Company LIKE 'Microsoft'";
Statement stmt = con.createStatement();
ResultSet rs2 = stmt.executeQuery(SQL2);
// RS Now contains the a Records with Microsoft.
What am I doing wrong?
Terje
Floroe, Norway
Terje Viken wrote:
--
BEA WebLogic: Voted The Best Web Application Server: JAVAWORLD
http://java.sun.com/events/jbe/98/features/ed.choice.html
BEA with WebLogic in the 12 most influential IT companies:
http://www.intelligententerprise.com/98dozen/frm_feat1.shtml
Joseph Weinstein <j...@weblogic.com> wrote:
: Try:
: Terje Viken wrote:
--
George Reese (bo...@imaginary.com) http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
"Keep Ted Turner and his goddamned Crayolas away from my movie."
-Orson Welles
Thanks for responding but I've tried this and it doesn't work! - Also tried
double quotes as well. - All example code I have seen does this without
quotes. - No go!
Teje
Joseph Weinstein skrev i meldingen <3693B1E4...@weblogic.com>...
I tried making a test table in Access and it worked like a dream. Also tried
making new tables with SQL Server using different String fields like char()
and varchar() - this had no effect . - I'm surprised this don't work in SQL
server since it's using ODBC. I'll have to check out my documentation a bit!
Thank you for responding! - ( Do you know anything useful about this
phenomenom please let me know!)
Terje
Terje Viken skrev i meldingen <770atn$bs$1...@elle.eunet.no>...
> If your solution works, it is a serious bug in the driver.
> Joseph Weinstein <j...@weblogic.com> wrote:
> : Try:
> : ps.setString(1, "'Microsoft'"); // note the inclusion of single-quotes inside the double-quotes
You're right, of course, the suggestion was just a 'savage hack' to see what the problem might be.
I wonder whose JDBC driver it is. The WebLogic JDBC driver for MS SQLServer works fine in
this way:
ps = conn.prepareStatement("select name from sysdatabases where name like ?");
ps.setString(1, "master"); // or "%" etc.
rs = ps.executeQuery();
System.out.println("retrieving...");
while (rs.next()) System.out.println("got " + rs.getString(1) );
System.out.println("done");
for "master" we give:
retrieving...
got master
done
for "%" we give:
retrieving...
got master
got model
got msdb
got pubs
got tempdb
done
Joe Weinstein at BEA, the home of WebLogic
I haven't had the pleasure of trying one of the pure JDBC drivers for SQL
Server yet!
Terje
Terje Viken wrote:
The JDBC-ODBC bridge is notoriously flakey, not supported, and
not suitable for commercial use. You can try our driver for free *with support*.
Please visit weblogic.com
Terje
Joseph Weinstein wrote in message <3693FAC5...@weblogic.com>...