| | |
JSP connection to database
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2005
Posts: 11
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2004
Posts: 8
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 9
Reputation:
Solved Threads: 0
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..
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..
- You should know that urgency on your side will not speed up process on our side, we have right to live too...
- 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/)
- Oracle website holds numerous examples, like these and you can have look also on How-To examples.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Aug 2008
Posts: 9
Reputation:
Solved Threads: 0
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..?
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..?
jsp Syntax (Toggle Plain Text)
<%@ 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>
Last edited by peter_budo; Nov 10th, 2008 at 4:47 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
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.
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.
Last edited by stephen84s; Nov 8th, 2008 at 2:54 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
•
•
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.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
Join Date: Aug 2008
Posts: 9
Reputation:
Solved Threads: 0
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]
but it is creating one more text box even if i give the same textbox name..
m new to JSP.. please do help..
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 Syntax (Toggle Plain Text)
<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..
![]() |
Similar Threads
- jsp code for values from database to textbox (JSP)
- JSP using Oracle Database (JSP)
- how to access the database within same jsp page (JSP)
- Problem with database connection (JSP)
- Please help me in connecting JSP to MySql (JSP)
- error due to accessing database connection using jsp (JSP)
- connecting jsp with oracle database (JSP)
Other Threads in the JSP Forum
- Previous Thread: Special Characters in JSP
- Next Thread: 3 drop down list
| Thread Tools | Search this Thread |
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






