Batch class gets driver error
Hello folks,
I have constructed a Java class that makes an update to Oracle.
Initially, I'd used the old Java Sun ODBC driver and it worked.
I changed to the Oracle thin driver, and now I get an error of, "java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver"
By the way; I've tried both
oracle.jdbc.OracleDriver
and
oracle.jdbc.driver.OracleDriver
as I've seen it referenced both ways, the latter being non-supported in future versions of Oracle from 9i on.
Any idea what would cause this? I use this in all of my servlets, where I'm not using connection pooling, without any problem.
Any feedback would be appreciated.
Thanks!
Here's my code of the app.
import java.io.IOException;
import java.sql.Connection;
//import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
publicclass BatchStandalone{
publicstaticvoid main(String[] args){
Connection connection;
try{
//changed driver ref -
Class.forName("oracle.jdbc.OracleDriver");
String dbURL ="jdbc:oracle:thin:@169.172.25.162:1521:CWOPS";
String usernm ="usr_acct";
String pwd ="password";
connection = DriverManager.getConnection(dbURL, usernm, pwd);
Statement datstmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rst = datstmt.executeQuery("SELECT SYSDATE FROM DUAL");
rst.next();
java.sql.Date sysdateret = rst.getDate("SYSDATE");
//java.util.Date sysdate2 = sysdateret.valueof();
//long dtvalue = sysdateret.getTime(sysdateret);
rst.close();
datstmt.close();
System.out.println("SQL Sysdate from Oracle: " +sysdateret);
//for VP dates
Statement outstdates = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet outdatrst = outstdates.executeQuery("SELECT VP_DATE FROM CHANGE_CONTROL_USER");
while (outdatrst.next()){
java.sql.Date vpdates = outdatrst.getDate(1);
}
// other vars declared here -- this is ok...
String preparedQuery ="UPDATE CHANGE_CONTROL_ADMIN b SET " +
"STATUS1 = 'Inactive', STATUS2 = 'Business Closed' " +
"where change_ctrl_id in " +
"(select a.change_ctrl_id FROM CHANGE_CONTROL_USER a " +
"WHERE a.VP_DATE <= ? AND a.VP_DATE >= ?) "+
"AND STATUS2 = 'Pending Level 1'";
System.out.println("SQL Stmt: " +preparedQuery);
PreparedStatement pstmt = connection.prepareStatement(preparedQuery);
pstmt.setDate(1, result);
pstmt.setDate(2, result30b);
pstmt.executeUpdate();
System.out.println(pstmt);
outdatrst.close();
outstdates.close();
pstmt.close();
connection.close();
}
catch(SQLException se){
while(se!=null){
System.out.println(se);
se = se.getNextException();
}
}
catch(Exception e){
System.out.println("[b]Update to Oracle not made[/b].");
System.out.println(e);
System.exit(1);
}
}
}

