I have tried this code in both JDeveloper 10g and Netbeans 3.5. I cannot get the DriverManager to recognize the oracle driver. I can connect to the database, but the driver isn't recognized. Here's my code:
import java.sql.*;
public class RequestSQL {
public static void main (
String args[]) {
//declare connection and stament objects
Connection myConnection = null;
Statement myStatement = null;
try {
//register the Oracle
JDBC DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//create the connection object, and connect to the database
// as user_name using the thin driver
//myConnection = DriverManager.getConnection("jdbc.default.connection");
myConnection = DriverManager.getConnection("jdbc

racle:thin@urlparameter", "login", "pwd");
//disable auto-commit mode
myConnection.setAutoCommit(false);
//create a Statement object
myStatement = myConnection.createStatement();
//create variables and objects to represent field values
int id = 40000419;
double no = 0.01;
String whatString = "A
Java test to see if Java classes are viable.";
java.sql.Date v_date = new java.sql.Date(2004, 3, 10);
//perform sql update to modify the what field of the Project Derscription section
myStatement.executeUpdate(
"Update table_name " +
"Set whatString = ' " + what + "' " +
"Where id = " + id
);
System.out.println("Updated row in thre tablename table.");
//Create a ResultSet object, and populate it with the result set of
//the SELECT statement that retrieves a given row of data
ResultSet requestResultSet = myStatement.executeQuery(
"Select id, no, v_date, whatString " +
"From tablename " +
"Where id between " + id + "and " + "999"
);
while(requestResultSet.next()) {
id = requestResultSet.getInt("id");
no = requestResultSet.getDouble("no");
v_date = requestResultSet.getDate("v_date");
whatString = requestResultSet.getString("whatString");
System.out.println("id = " + id);
System.out.println("no = " + no);
System.out.println("v_date = " + v_date);
System.out.println("whatString = " + whatString);
}
//close the object
requestResultSet.close();
//rollback changes made to the database
myConnection.rollback();
} catch (SQLException e) {
System.out.println("Error code = " + e.getErrorCode());
System.out.println("Error message = " + e.getMessage());
System.out.println("SQL statement = " + e.getSQLState());
e.printStackTrace();
} finally {
try {
//close the Statement obj
if(myStatement != null) {
myStatement.close();
}
//close the connection object using the close() method
if(myConnection != null) {
myConnection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}