String.contains works in jdk 6, not in 1.4.2
The below snippet (swiped from Programming tutorials and source code examples) compiles and runs in jdk 6, but throws an exception in jdk 1.4.2 ( I have to make a jre 1.5 compatible executable, and only have access to the two different jdk's at present)
Code:
.
.
.
Class.forName ("oracle.jdbc.OracleDriver");
// Enable logging
// DriverManager.setLogStream(System.err);
System.out.println("Getting Connection");
Connection conn = DriverManager.getConnection (
"jdbc:oracle:thin:@192.168.0.77:1521:dbname", "user", "passwd");
// Any warnings generated by the connect?
checkForWarning(conn.getWarnings());
System.out.println("Creating Statement");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE_NAME");
System.out.println("Retrieving Results");
int i = 0;
while (rs.next()) {
System.out.println("Retrieving ID");
int iID = rs.getInt("ID");
System.out.println("Retrieving Name");
String sName = rs.getString("NAME");
if (sName.contains("XXXXX")){
System.out.println("Found XXXXX");
}
System.out.println(sName);
//System.out.println("ROW " + ++i + ": " + iID + "; " + sName + "; " + ".");
}
.
.
.
The error is:
Code:
DBConnectionTest.java:58: cannot resolve symbol
symbol : method contains (java.lang.String)
location: class java.lang.String
if (sName.contains("XXXXX")){
For the life of me, I cannot see any difference in the String.contains and ResultSet.GetString methods in 1.4.2 and 6 API docs, so I'm just giving up on RTFM and STFW and am going to break down and ask just what the heck I'm doing wrong?
Again, the code compiles and runs in java 6, but chokes in 1.4.2. The two different jdks are on two different systems. jdk 6 is on a Windows XP workstation, and the 1.4.2 jdk is on a Linux server.
Thanks,
Scott