hi guys

hope you can help

well im tryin to connect my jsp to my database, im uisng tomcat 5 and have stored the MS access database in my ROOT folder.

i have created a User DNS, and have sdk 1.4.2_08 installed

Problem is im not sure what to do now??

do i have to install a sun driver? if so how?

and finally how do i connect to teh database?

Please help thanks! x

Hi nelly

No need to do much
I hope u are aware of JDBC-ODBC Driver and they are supported by sdk1.4

First create a DSN using ODBC in control pannel
later for JSP to connect to Database

use the following code

<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:<DSN name>")
%

provide DSN name after the second colon.
In this way you are connected to your data base and you can futher query your database using statement object .

For futher help
mail adityabakle@gmail.com

Hi!..
can anyone help me.. This is urgent..
M doing a project in JSP.. m using Tomcat 4.1..
I want to connect oracle 10g xe as back end..
I have never done that before with anyother database application..
can anyone tel me step by step procedure for that..
Do i have to install any drivers for that..

  1. You should know that urgency on your side will not speed up process on our side, we have right to live too...
  2. Any reason for Tomcat 4 when there s Tomcat 6? If not, either use latest Tomcat 5 or go for Tomcat 6 as is working fine. (http://tomcat.apache.org/)
  3. Oracle website holds numerous examples, like these and you can have look also on How-To examples.

can anyone help me here..

M doing a project in JSP.. M using oracle 10g.. m able to retrieve data from the oracle table.. but m not able to insert.. This code is not showing any error but it is not getting inserted.. do we have to install any drivers..?

<%@ page language ="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>



<html>
<head>
<title>sample</title>
</head>

<form method="post">

UserName:
<input type="text" fname="t1" >
<br>
<input type="text" lname="t2" >
<br>
<input type="submit" name="sub">

<%
String fname=request.getParameter("t1");
String lname=request.getParameter("t2");
%>

<%
try{

                 Class.forName("sun.jdbc.odbc.JdbcOdbc");
 Connection con=DriverManager.getConnection("jdbc:odbc:MyDatabase","system","database");

PreparedStatement st; 
st = con.prepareStatement("Insert into ch values (1,2)");
st.setString(1,fname);
st.setString(2,lname);
st.executeUpdate();

	
	 
%>
<%	   
}


catch(Exception e1)
{
out.println("cannot display the records");
}
%>
</form>
</body>
</html>

First thing Amrita is DO NOT CONNECT DIRECTLY TO A DATABASE FROM A JSP.
It is a bad practice to do so. It looks like you are still just studying JSPs, so from the start itself learn how to correctly design you web applications by separating the processing logic and the User Interface. Check this thread by Peter for a good tutorial on how you should go about development is JSPs.
And one more thing please use code tags while posting code, look here for more information.

Note:-
A quick fix exists but I simply will not give it to you cause, you would then just implement the quick fix and skip the rest of the advice.

Thank you very much..
that link was really helpful..

can anyone tell me how to make appear strings to appear in text box when i click a button.. i have multiple buttons on my form..
m doing a project in JSP..
i have tried using textarea but it is showing error.. is there any other alternative.?
with short examples will be more helpfull..

can anyone tell me how to make appear strings to appear in text box when i click a button.. i have multiple buttons on my form..
m doing a project in JSP..
i have tried using textarea but it is showing error.. is there any other alternative.?
with short examples will be more helpfull..

That query would belong to the Javascript forum (*I guess*), But you have to show us the relevant piece of code, So that we can point out where you are going wrong.
If you still would like to get some code samples I suggest you look at the Code Snippets section of Daniweb to see if you can find something useful or else google is your friend.

i want some help here..

i want to display records in text boxes when i click a button..
for eample: there are 3 text boxes..
cid,cname,cadd.. when i type the cid in first field other information ie, cname and cadd should also appear automatically from
databse.. i have multiple submit buttons on my page..

i tried the following method..

[code=jsp]
<input type="textbox" id="tb1" name="tb1" value="<%= rs.fields("column") %>" />

but it is creating one more text box even if i give the same textbox name..
m new to JSP.. please do help..

hi guys
Hi
check the compability of both means tomcat 5 work on jdk1.4 or not
i think tomcat 5 required jdk1.5 means jdk5.0 version
Regards
Pramesh

commented: Unnecessarily reviving an old and useless thread with information of little value -1

we can connect the jsp page with database also by datasource. in datasource procedure
we are creating first a jdvc provider then create a datasource. then give some authentication and name of server like server1 or manager01 etc..
then give database name to which we want to connect.
and then give the test coneection command.
and get the successfully connection with that database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.