Posted By:
leo_mendoza
Posted On:
Wednesday, June 12, 2002 08:11 AM
What am I doing wrong here? The DSN is setup correctly, and running it via command line works. Env: JDK 1.3, Win2K, JRun 3 Please help /** * CCTAdmin_Check.java * Checks the database to see if the user is authorized or not **/ import java.io.*; import java.sql.*; class CCTAdmin_Check implements Serializable { private Connection c = null; public boolean isAuthorizedUser(String un, String pw, String sid) { boolean retVal = false; Statement s = null; String sql = "SELECT userid FROM CCT_AuthUsers WHERE UserLogin = '" + un + "' AND password = '" + pw + "';"
More>>
What am I doing wrong here?
The DSN is setup correctly, and running it via command line works.
Env: JDK 1.3, Win2K, JRun 3
Please help
/**
* CCTAdmin_Check.java
* Checks the database to see if the user is authorized or not
**/
import java.io.*;
import java.sql.*;
class CCTAdmin_Check implements Serializable {
private Connection c = null;
public boolean isAuthorizedUser(String un, String pw, String sid) {
boolean retVal = false;
Statement s = null;
String sql = "SELECT userid FROM CCT_AuthUsers WHERE UserLogin = '" +
un + "' AND password = '" + pw + "';";
try {
if(c == null) {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
/*
c = DriverManager.getConnection(
"jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Site Mirror/test.mdb",
"","");
*/
c = DriverManager.getConnection(
"jdbc:odbc:TestCCTDS",
"","");
} //end if
s = c.createStatement();
ResultSet rs = s.executeQuery(sql);
//if the record is found, then the sid is is stored in the DB
if(rs.next())
if (s.executeUpdate("UPDATE CCT_AuthUsers SET sid = '" + sid +
"', LastLogin = NOW() WHERE userid = " + rs.getString("userid") + ";") != 0)
retVal = true;
} catch (SQLException e) {
System.out.println("SQL Error occurred!
" + e.getMessage() + "
" + e.toString());
} catch (ClassNotFoundException e) {
System.out.println("Class not found!
" + e.getMessage() + "
" + e.toString());
} //end try/catch
try { //close up the connection
if(c != null) c.close();
} catch (Throwable t) {
System.out.println("Could not close connection");
} //end try/catch
return retVal;
} //end isAuthorizedUser
public static void main(String [] args) {
System.out.println("is auth? " +
new CCTAdmin_Check().isAuthorizedUser(args[0],args[1],args[2]));
} //end main
} //end Admin
The error I get is:
javax.servlet.ServletException:
on line '1' failed.
java.lang.IllegalAccessException: CCTAdmin_Check
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:232)
at allaire.jrun.jsp.JRunJSPStaticHelpers.createBean(../jsp/JRunJSPStaticHelpers.java:274)
at allaire.jrun.jsp.JRunJSPStaticHelpers.getAndSetBean(../jsp/JRunJSPStaticHelpers.java:224)
at jrun__Admin__checkCredentials2ejsp1b._jspService(jrun__Admin__checkCredentials2ejsp1b.java:39)
at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:40)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
at allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatcher.java:34)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:175)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:88)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1131)
at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:330)
at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:107)
at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
TIA -
leo