El código de la clase es:
Código:
que es llamado desde un servlet (omito el html del servlet):package accessdatabase; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import oracle.jdbc.OracleDriver; import oracle.jdbc.OracleTypes; import oracle.jdbc.driver.OracleCallableStatement; public class ConsultasBBDD { //CONSULTAMOS QUE EL NUEVO USUARIO NO ESTÉ REGISTRADO DE ANTEMANO private static String userQuery = ""; public static String getObtenerInformacionUsuarioBBDD(String nombre) { String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE"; String query = "SELECT * FROM RSF_USUARIOS WHERE NOMBRE='"+nombre+"'"; System.out.println(query); String newid =""; try { // Load the jdbc-odbc bridge driver Connection cn; Statement st; Class.forName ("oracle.jdbc.driver.OracleDriver"); //Utiliza el driver JDBC-ODBC o OracleDriver para conectar a la DB cn = DriverManager.getConnection(url, "system", "1234"); //Consulta SQL se manejan con el método createStatement() st = cn.createStatement(); //La consulta puede ser execute(query) o executeUpdate(query) o executeQuery(query) //Ejecutamos una consulta que devuelve un objeto Resulset al invocar el método executeQuery del objeto st //Por lo que creamos el objeto Resulset ResultSet rs = st.executeQuery(query); while (rs.next()){ newid = rs.getString(4); System.out.println("El valor consultado es "+nombre+" y su id es "+newid); //password = rs.getString(4); } // Close the result set rs.close(); cn.close(); // Close the statement } catch (SQLException ex) { ex.printStackTrace (); }catch (java.lang.Exception ex) { // Got some other type of exception. Dump it. ex.printStackTrace (); } return newid; } }
Código:
String usuario = request.getParameter("usuario"); String password = request.getParameter("password"); String MD5password = MD5.digest(usuario, password); System.out.println("Ha introducido "+usuario+" y "+password); System.out.println("Que se convertirá en "+usuario+" y "+MD5password); String usuarioBBDD = ConsultasBBDD.getObtenerInformacionUsuarioBBDD(usuario);
Me da un error
Invalid file specified for console output: ${workspace_loc:/00ReporterosSinFronteras/build/classes/InputData.class}]
19-may-2009 18:46:40 org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:01HolaMundo' did not find a matching property.
19-may-2009 18:46:40 org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:00ReporterosSinFronter as' did not find a matching property.
19-may-2009 18:46:40 org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:03DoGetDoPostServlet' did not find a matching property.
19-may-2009 18:46:40 org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:12Login_JSP' did not find a matching property.
19-may-2009 18:46:40 org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:02Login____NO' did not find a matching property.
19-may-2009 18:46:40 org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:06ProductosServlets___ NO' did not find a matching property.
19-may-2009 18:46:40 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\W indows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\oraclexe\app\oracle\product\10.2.0\server\b in;C:\Windows\system32;C:\Windows;C:\Windows\Syste m32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Dev-Cpp\bin;C:\Program Files\QuickTime\QTSystem\;C:\MinGW;C:\Program Files\Common Files\Nero\Lib\
19-may-2009 18:46:40 org.apache.coyote.http11.Http11Protocol init
INFO: Inicializando Coyote HTTP/1.1 en puerto http-8082
19-may-2009 18:46:40 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1488 ms
19-may-2009 18:46:40 org.apache.catalina.core.StandardService start
INFO: Arrancando servicio Catalina
19-may-2009 18:46:40 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
19-may-2009 18:46:42 org.apache.coyote.http11.Http11Protocol start
INFO: Arrancando Coyote HTTP/1.1 en puerto http-8082
19-may-2009 18:46:43 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
19-may-2009 18:46:43 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/41 config=null
19-may-2009 18:46:43 org.apache.catalina.startup.Catalina start
INFO: Server startup in 2371 ms
Ha introducido roberto y l
Que se convertirá en roberto y 02a7aee256ed2cc451fa6dc1c12b28e8
SELECT * FROM RSF_USUARIOS WHERE NOMBRE='roberto'
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at accessdatabase.ConsultasBBDD.getObtenerInformacion UsuarioBBDD(ConsultasBBDD.java:32)
at registro.InputDataBase.doPost(InputDataBase.java:8 5)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
y que no consigo adivinar que es. El driver ojdbc14.jar lo he añadido a la libreria que he creado en el proyecto llamada driveroracle con el build path. ¿Me podéis ayudar?
Gracias.