•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 391,656 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,763 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1186 | Replies: 3
![]() |
i am using tomcat 5.5,but i am unable to connect to database
<HTML>
<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY bgcolor="#8D9BCA" text="#333300" marginheight="0" marginwidth="0">
<center>
<!-- row 2 -->
<table height="1" width="381">
<td height="1" width="373">
<P align="center">
<P align="center">
<p align="center"><span style="letter-spacing: 1pt"><b><font size="3" face="Bookman Old Style">Login
Form for Clients</font></b></span></p>
<p align="center"> </p>
<form action="clientcheck.jsp" method="POST">
<div align="center">
<table border="0" width="50%" cellspacing="5" cellpadding="5" height="80">
<tr>
<td width="33%" align="center" height="25">
<p align="center"><font size="3" face="Bookman Old Style">Client ID </font></p>
</td>
<td width="33%" height="25">
<p align="center"><font size="3" face="Bookman Old Style"><input type="text" name="client_id" size="20"></font></p>
</td </tr>
<tr>
<td width="33%" align="center" height="23">
<p align="center"><font size="3" face="Bookman Old Style">Password </font></p>
</td>
<td width="33%" height="23">
<p align="center"><font size="3" face="Bookman Old Style"><input type="password" name="client_password" size="20"></font></p>
</td>
</tr>
</table>
</div>
<p align="center"><font size="3" face="Bookman Old Style">
If new user <a href="registration_form.htm">Sign
up</a></font></p>
<p align="center"><b><font color="#008000" size="3" face="Bookman Old Style">
<input type="submit" value=" Go " name="submit"></span>
<input type="reset" value="Reset" name="reset">
</span>
</font></b></p>
<p align="center"> </p>
<p align="center"> </p>
</form>
</td>
</table>
</center>
</BODY>
</html>
clientcheck.jsp
<%@ page import="java.sql.*" %>
<html>
<BODY bgcolor="#8D9BCA" text="#333300" marginheight="0" marginwidth="0">
<%
//Context ctx=null;
ResultSet rs;
Connection con;
Statement st;
String clientid;
String password;
int arraylen;
clientid=request.getParameter("client_id");
password=request.getParameter("client_password");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Nikki","","");
st = con.createStatement();
rs=st.executeQuery("select * from clientlogin ");
//rs = st.getResultSet();
while(rs.next()){
String clientid1= rs.getString("client_id");
String pwd1=rs.getString("password");
if((clientid.equals(clientid1))&&(password.equals(pwd1)))
{
session.setAttribute("CLIENT_ID",clientid);
out.println(clientid);
}
}
}
catch(Exception e)
{
out.println(e.toString());
}
%>
</body>
</html>
i created dsn name correctly.After i open browser http://localhost:8080/login/clientlogin.html
it is excuted & sent to next page but i am getting error
SQL EXCEPTION:GeneralError
for tomcat do i need to install jsdk and do i need to create war file plz tell me how to create war file .
<HTML>
<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY bgcolor="#8D9BCA" text="#333300" marginheight="0" marginwidth="0">
<center>
<!-- row 2 -->
<table height="1" width="381">
<td height="1" width="373">
<P align="center">
<P align="center">
<p align="center"><span style="letter-spacing: 1pt"><b><font size="3" face="Bookman Old Style">Login
Form for Clients</font></b></span></p>
<p align="center"> </p>
<form action="clientcheck.jsp" method="POST">
<div align="center">
<table border="0" width="50%" cellspacing="5" cellpadding="5" height="80">
<tr>
<td width="33%" align="center" height="25">
<p align="center"><font size="3" face="Bookman Old Style">Client ID </font></p>
</td>
<td width="33%" height="25">
<p align="center"><font size="3" face="Bookman Old Style"><input type="text" name="client_id" size="20"></font></p>
</td </tr>
<tr>
<td width="33%" align="center" height="23">
<p align="center"><font size="3" face="Bookman Old Style">Password </font></p>
</td>
<td width="33%" height="23">
<p align="center"><font size="3" face="Bookman Old Style"><input type="password" name="client_password" size="20"></font></p>
</td>
</tr>
</table>
</div>
<p align="center"><font size="3" face="Bookman Old Style">
If new user <a href="registration_form.htm">Sign
up</a></font></p>
<p align="center"><b><font color="#008000" size="3" face="Bookman Old Style">
<input type="submit" value=" Go " name="submit"></span>
<input type="reset" value="Reset" name="reset">
</span>
</font></b></p>
<p align="center"> </p>
<p align="center"> </p>
</form>
</td>
</table>
</center>
</BODY>
</html>
clientcheck.jsp
<%@ page import="java.sql.*" %>
<html>
<BODY bgcolor="#8D9BCA" text="#333300" marginheight="0" marginwidth="0">
<%
//Context ctx=null;
ResultSet rs;
Connection con;
Statement st;
String clientid;
String password;
int arraylen;
clientid=request.getParameter("client_id");
password=request.getParameter("client_password");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Nikki","","");
st = con.createStatement();
rs=st.executeQuery("select * from clientlogin ");
//rs = st.getResultSet();
while(rs.next()){
String clientid1= rs.getString("client_id");
String pwd1=rs.getString("password");
if((clientid.equals(clientid1))&&(password.equals(pwd1)))
{
session.setAttribute("CLIENT_ID",clientid);
out.println(clientid);
}
}
}
catch(Exception e)
{
out.println(e.toString());
}
%>
</body>
</html>
i created dsn name correctly.After i open browser http://localhost:8080/login/clientlogin.html
it is excuted & sent to next page but i am getting error
SQL EXCEPTION:GeneralError
for tomcat do i need to install jsdk and do i need to create war file plz tell me how to create war file .
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,134
Reputation:
Rep Power: 10
Solved Threads: 257
Please don't abuse power and beauty of JAVA, scriplets are no place for setting connection to database. Use servlet...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,646
Reputation:
Rep Power: 18
Solved Threads: 191
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
- can solve this problem? (C)
- friend plz help me to solve this problem (C++)
- plzz solve my problem (C++)
- Anyway can help me to solve this problem??? (C++)
- public pathroom problem (plz help) (Java)
- CDBException can't solve problem (ASP.NET)
- i have problem with array plz help (Java)
- c language problm, how to pass pointer to a function (C)
- please help been at my pc for hours still cannot solve problem (Viruses, Spyware and other Nasties)
Other Threads in the JSP Forum
- Previous Thread: Connecting JSP to Oracle, problems with table
- Next Thread: How to send Email from JSP Page



Linear Mode