Topic
  • 3 replies
  • Latest Post - ‏2012-06-18T03:38:13Z by gipsa_j
gipsa_j
gipsa_j
3 Posts

Pinned topic problem in connecting to db2 while checking UN,PW, in db, from login page

‏2012-06-17T04:23:50Z |
I'm a beginner in using Rad and db2.
I have DB2 v10 and RAD v8.0.4.
I have a table named 'login' in schema called 'dbadmin'. There are 3 cols in this table.
'card_id', 'uname', 'pwd' and three different rows.

Now i have 2 jsp pages namely 'login.jsp' and 'check.jsp'. I'm facing difficulty while checking the db
with user given inputs in login page. It's just giving me a blank page and some error.
please, can anybody help me in solving this problem?
kindly reply soon, cause it's urgent...
Updated on 2012-06-18T03:38:13Z at 2012-06-18T03:38:13Z by gipsa_j
  • SystemAdmin
    SystemAdmin
    5837 Posts

    Re: problem in connecting to db2 while checking UN,PW, in db, from login page

    ‏2012-06-17T19:08:34Z  
    Check the application message returned by the JDBC driver and any relevant messages in db2diag.log

    Regards
    Yves-Antoine Emmanuelli
  • gipsa_j
    gipsa_j
    3 Posts

    Re: problem in connecting to db2 while checking UN,PW, in db, from login page

    ‏2012-06-18T01:51:49Z  
    Check the application message returned by the JDBC driver and any relevant messages in db2diag.log

    Regards
    Yves-Antoine Emmanuelli
    Hi,
    This is the program and error message that i get.'card_id','uname' and 'pwd' are the columns for the table 'login' in the db. And three rows are already inserted.
    Initially the login page is displayed and the user will enter the details. This is then passed to 'check.jsp' for db authentication.The main problem is while authentication. It reads the details from user, but then, failure message is displayed..
    please help me finding out the mistake in this code..
    check.jsp:

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>login</title>
    </head>
    <body><%@ page import="java.util.,java.sql.,java.io.*"%>
    <%
    try {
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    }
    catch (ClassNotFoundException e) {
    System.out.println("Please include Classpath Where your DB2 Driver is located");
    e.printStackTrace();
    return;
    }
    System.out.println("DB2 driver is loaded successfully");
    String sid = request.getParameter("sid");
    String un = request.getParameter("username");
    String pw = request.getParameter("password");
    Connection con=null;
    PreparedStatement pstmt = null;
    ResultSet rset=null;
    boolean found=false;
    try {
    con = DriverManager.getConnection(
    "jdbc:db2://localhost:50000/CIM", "db2admin",
    "db2admin");
    if (con != null)
    {
    System.out.println("DB2 Database Connected");
    }
    else
    {
    System.out.println("Db2 connection Failed ");
    }
    pstmt=con.prepareStatement("Select * from dbadmin.login");
    rset=pstmt.executeQuery();
    if(rset!=null)
    {

    while (rset.next())
    {
    found=true;
    System.out.println("sid: "+rset.getString("card_id"));
    System.out.println("username: "+rset.getString("uname"));
    System.out.println("password: "+rset.getString("pwd"));
    if((sid.equals(rset.getString("+card_id")))&&(un.equals(rset.getString("+uname")))&&(pw.equals(rset.getString("+pwd"))))
    {

    %>
    <jsp:forward page="login_successfull.jsp"></jsp:forward>
    <%
    }
    else
    {
    %>
    <jsp:forward page="error_message.jsp"></jsp:forward>
    <%
    }
    %>
    </body>
    </html>
    Error message from console:

    DB2 driver is loaded successfully
    com.ibm.db2.jcc.am.SqlException: jcc1015010300http://4.13.127 Invalid parameter: Unknown column name +card_id. ERRORCODE=-4460, SQLSTATE=null
    at com.ibm.db2.jcc.am.id.a(id.java:661)
    at com.ibm.db2.jcc.am.id.a(id.java:60)
    at com.ibm.db2.jcc.am.id.a(id.java:103)
    at com.ibm.db2.jcc.am.hb.a(hb.java:2117)
    at com.ibm.db2.jcc.am.bo.a(bo.java:1932)
    at com.ibm.db2.jcc.am.bo.getString(bo.java:1704)
    at org.apache.jsp.login_jsp._jspService(login_jsp.java:115)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)DB2 Database Connected
    sid: 09qm67gh4
    username: anna
    password: gh4anna
    DB2 Database connection Failed

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
    thanks,
    gipsa
  • gipsa_j
    gipsa_j
    3 Posts

    Re: problem in connecting to db2 while checking UN,PW, in db, from login page

    ‏2012-06-18T03:38:13Z  
    • gipsa_j
    • ‏2012-06-18T01:51:49Z
    Hi,
    This is the program and error message that i get.'card_id','uname' and 'pwd' are the columns for the table 'login' in the db. And three rows are already inserted.
    Initially the login page is displayed and the user will enter the details. This is then passed to 'check.jsp' for db authentication.The main problem is while authentication. It reads the details from user, but then, failure message is displayed..
    please help me finding out the mistake in this code..
    check.jsp:

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>login</title>
    </head>
    <body><%@ page import="java.util.,java.sql.,java.io.*"%>
    <%
    try {
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    }
    catch (ClassNotFoundException e) {
    System.out.println("Please include Classpath Where your DB2 Driver is located");
    e.printStackTrace();
    return;
    }
    System.out.println("DB2 driver is loaded successfully");
    String sid = request.getParameter("sid");
    String un = request.getParameter("username");
    String pw = request.getParameter("password");
    Connection con=null;
    PreparedStatement pstmt = null;
    ResultSet rset=null;
    boolean found=false;
    try {
    con = DriverManager.getConnection(
    "jdbc:db2://localhost:50000/CIM", "db2admin",
    "db2admin");
    if (con != null)
    {
    System.out.println("DB2 Database Connected");
    }
    else
    {
    System.out.println("Db2 connection Failed ");
    }
    pstmt=con.prepareStatement("Select * from dbadmin.login");
    rset=pstmt.executeQuery();
    if(rset!=null)
    {

    while (rset.next())
    {
    found=true;
    System.out.println("sid: "+rset.getString("card_id"));
    System.out.println("username: "+rset.getString("uname"));
    System.out.println("password: "+rset.getString("pwd"));
    if((sid.equals(rset.getString("+card_id")))&&(un.equals(rset.getString("+uname")))&&(pw.equals(rset.getString("+pwd"))))
    {

    %>
    <jsp:forward page="login_successfull.jsp"></jsp:forward>
    <%
    }
    else
    {
    %>
    <jsp:forward page="error_message.jsp"></jsp:forward>
    <%
    }
    %>
    </body>
    </html>
    Error message from console:

    DB2 driver is loaded successfully
    com.ibm.db2.jcc.am.SqlException: jcc1015010300http://4.13.127 Invalid parameter: Unknown column name +card_id. ERRORCODE=-4460, SQLSTATE=null
    at com.ibm.db2.jcc.am.id.a(id.java:661)
    at com.ibm.db2.jcc.am.id.a(id.java:60)
    at com.ibm.db2.jcc.am.id.a(id.java:103)
    at com.ibm.db2.jcc.am.hb.a(hb.java:2117)
    at com.ibm.db2.jcc.am.bo.a(bo.java:1932)
    at com.ibm.db2.jcc.am.bo.getString(bo.java:1704)
    at org.apache.jsp.login_jsp._jspService(login_jsp.java:115)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)DB2 Database Connected
    sid: 09qm67gh4
    username: anna
    password: gh4anna
    DB2 Database connection Failed

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
    thanks,
    gipsa
    Sorry, the code i posted previously was not complete. This is the complete code.

    check.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>login</title>
    </head>
    <body><%@ page import="java.util.,java.sql.,java.io.*"%>
    <%
    try {
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    }
    catch (ClassNotFoundException e) {
    System.out.println("Please include Classpath Where your DB2 Driver is located");
    e.printStackTrace();
    return;
    }
    System.out.println("DB2 driver is loaded successfully");
    String sid = request.getParameter("sid");
    String un = request.getParameter("username");
    String pw = request.getParameter("password");
    Connection con=null;
    PreparedStatement pstmt = null;
    ResultSet rset=null;
    boolean found=false;
    try {
    con = DriverManager.getConnection(
    "jdbc:db2://localhost:50000/CIM", "db2admin",
    "db2admin");
    if (con != null)
    {
    System.out.println("DB2 Database Connected");
    }
    else
    {
    System.out.println("Db2 connection Failed ");
    }
    pstmt=con.prepareStatement("Select * from dbadmin.login");
    rset=pstmt.executeQuery();
    if(rset!=null)
    {

    while (rset.next())
    {
    found=true;
    System.out.println("sid: "+rset.getString("card_id"));
    System.out.println("username: "+rset.getString("uname"));
    System.out.println("password: "+rset.getString("pwd"));
    if((sid.equals(rset.getString("+card_id")))&&(un.equals(rset.getString("+uname")))&&(pw.equals(rset.getString("+pwd"))))
    {

    %>
    <jsp:forward page="login_successfull.jsp"></jsp:forward>
    <%
    }
    else
    {
    %>
    <jsp:forward page="error_message.jsp"></jsp:forward>
    <%
    }
    }
    if (found ==false)
    {
    System.out.println("No Information Found");
    }
    }
    }
    catch (SQLException e) {
    System.out.println("DB2 Database connection Failed");
    e.printStackTrace();
    return;
    }
    %>
    </body>
    </html>