Cita:
El código que utilizo es el que sigue : java.sql.SQLException: [SQL0401] Operandos de operador de comparación = no compatibles.
Código HTML:
package uct; import java.io.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.PreparedStatement; import javax.servlet.*; import javax.servlet.http.*; public class jspcon extends HttpServlet { protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); Connection con = null; PreparedStatement stmt = null; ResultSet rset = null; Connection conAS = null; PreparedStatement stmtAS = null; ResultSet rsetAS = null; String userAS = "user"; String passwordAS = "pass"; String host = "IP"; String driver = "oracle.jdbc.driver.OracleDriver"; String source = "jdbc:oracle:thin:@IP:1521:aleph0"; String user = "user"; String password = "pass"; try { // Conexión a Oracle Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); con = DriverManager.getConnection(source, user, password); // Conexión a DB2 Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance(); // Class.forName(com.ibm.as400.acces.AS400JDBCDriver); conAS = DriverManager.getConnection("jdbc:as400://"+host,userAS, passwordAS); try { // Recojo la variable enviada por la página JSP String rut1 = request.getParameter("rut1"); String rut2 = request.getParameter("rut2"); String rutOra = rut1+rut2; // String rutAS = request.getParameter("rut"); String rutAS = "0"+rut1; // Asigno esa variable dentro del Query stmt = con.prepareStatement ("SELECT z36_id , z30_barcode, z36_loan_date, z36_due_date, z36_returned_date, z30_sub_library FROM z36, z30 WHERE (z36_rec_key = z30_rec_key) and (z36_due_date < '20050405') and z36_id = '" +rutOra+ "'"); rset = stmt.executeQuery(); stmtAS = conAS.prepareStatement ("SELECT ALN_NOMBRE, ALN_REGISTRO, CAR_CARRERA FROM UCCURR.ALUMNOS inner join UCCURR.CARRERAS on ALN_CARRERA = CAR_CARRERA WHERE ALN_RUT_ALUMNO= '" +rutAS+"'"); rsetAS = stmtAS.executeQuery(); out.println("<BODY bgcolor='#0066CC'></BODY>"); out.println("<TITLE>CONSULTA DE DEUDA EN BIBLIOTECA</TITLE>"); out.println("<h1 align='center'><FONT COLOR='#99CC33'>RESULTADO DE LA CONSULTA</FONT></h1>"); while (rsetAS.next()) { out.println("NOMBRE: " + rsetAS.getString("ALN_NOMBRE")); out.println("REGISTRO: " + rsetAS.getString("ALN_REGISTRO")); out.println("CARRERA: " + rsetAS.getString("CAR_CARRERA")); } out.println("<TABLE border='5' align='center' width='75%' border='1'>"); out.println("<TR>"); out.println("<td align='center'><FONT COLOR='white'>RUT</FONT></td>"); out.println("<td align='center'><FONT COLOR='white'>COD.BARRAS</FONT></td>"); out.println("<td align='center'><FONT COLOR='white'>FECHA PRESTAMO</FONT></td>"); out.println("<td align='center'><FONT COLOR='white'>FECHA DEVOLUCION</FONT></td>"); out.println("<td align='center'><FONT COLOR='white'>DEVOLUCION</FONT></td>"); out.println("<td align='center'><FONT COLOR='white'>BIBLIOTECA</FONT></td>"); out.println("</TR>"); while (rset.next()) { out.println("<TR>"); out.println("<td ALIGN='CENTER'><FONT COLOR='#99CC33'>" + rset.getString("z36_id") + "</FONT></td>"); out.println("<td ALIGN='CENTER'><FONT COLOR='#99CC33'>" + rset.getString("z30_barcode") + "</FONT></td>"); out.println("<td ALIGN='CENTER'><FONT COLOR='#99CC33'>" + rset.getString("z36_loan_date") + "</FONT></td>"); out.println("<td ALIGN='CENTER'><FONT COLOR='#99CC33'>" + rset.getString("z36_due_date") + "</FONT></td>"); out.println("<td ALIGN='CENTER'><FONT COLOR='#99CC33'>" + rset.getString("z36_returned_date") + "</FONT></td>"); out.println("<td ALIGN='CENTER'><FONT COLOR='#99CC33'>" + rset.getString("z30_sub_library") + "</FONT></td>"); out.println("<TR>"); } out.println("</TABLE>"); }catch(Exception ex) { out.println(ex.toString()); } }catch (Exception e) { out.println("Error conexion" + e.toString()); }finally { try { rset.close(); stmt.close(); con.close(); rsetAS.close(); stmtAS.close(); conAS.close(); } catch (Exception ex) { System.out.println(ex.toString()); } } } }