Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2005, 01:12 PM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default database connection

hi
again sandi here. i am tring to connect to database using ODBC_JDBC bridge but get the following error

"javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

[u]my html page</u><html>
<head>
<title>registration</title>

</head>

<body>
<form action="add2.jsp" method="get" name="registration">
<label> name </label><input name="studentid" type="text" size="50" maxlength="50">
<br>
<label>roll no</label><input name="rollnumber" type="text" size="30" maxlength="20">
<br>
<label>stream</label><input name="stream" type="text" size="40" maxlength="30">
<br><br><br>
<input name="submit" type="submit" value="Submit">
</form>

</body>
</html>

[u]and my add2.jsp </u>


<html>
<head>
<title>add student</title>

</head>

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

<body>

 <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:sandipa n","scott","tiger");

        String student_id=request.getParameter("studentid");
        String roll_number=request.getParameter("rollnumber");
        String stu_stream=request.getParameter("stream");

        Statement st=con.createStatement();
        int check=st.executeUpdate("insert into SANDIPAN values('" + student_id + "','" + roll_number + "','" + stu_stream + "')");

        if(check==1) {

%>

<h2>Sucessfull addition of new student</h2>

<%
    }
    else {
%>

<h2> Failed</h2>

<%
    }
    st.close();
    con.close();
%>


</body>
</html>


 i create the DSN named sandipan.test connection was sucessfull.

i need to say another thing. i downloaded exe file of tomcat5.0.30 and install it.and set CATALINA_HOME and JAVA_HOME.i didn't do anything esle except that. Is this enough to configure tomcat?

plz guys help me out.

thanks in advance.
sandi


 
Old April 22nd, 2005, 11:58 PM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if i dont bad remember, the version of the tomcat that u use needs the java 1.5,
with what type of database you try to connect, access or sql server?

the error is of configuration, strange case

DR POMPEII, THE PLACE OF THE OBLIVION OF GOD
 
Old May 2nd, 2005, 05:51 AM
Authorized User
 
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That is enough to configure tomcat. Something u need to know, that the parameter taken for Class.forName(something)--> something can be "com.mysql.jdbc.Driver" and can be "org.mm.gjt.mysql.Driver"......
jdbc:odbc:sandipan","scott","tiger" can be jdbc:odbc:///sandipan","scott","tiger"

Best regards,

Randhy

 
Old May 2nd, 2005, 07:41 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
if u are connecting to SQL Server running on the same computer then try using

oConn.Open "Driver={SQL Server};" & _
           "Server=(local);" & _
           "Database=myDatabaseName;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"

Here oConn is the connection object.

To connect to SQL Server running on a remote computer (via an IP address)

oConn.Open "Driver={SQL Server};" & _
           "Server=xxx.xxx.xxx.xxx;" & _
           "Address=xxx.xxx.xxx.xxx,1433;" & _
           "Network=DBMSSOCN;" & _
           "Database=myDatabaseName;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"
Where:
- xxx.xxx.xxx.xxx is an IP address
- 1433 is the default port number for SQL Server.
- "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named
   Pipes (Q238949)
Hope this would solve ur problem.


Best regards,

Renga






Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Database Connection oneillg PHP Databases 1 October 17th, 2007 04:48 PM
Database Connection kapi.goel SQL Language 2 February 14th, 2006 07:01 PM
database connection Nitin_sharma Classic ASP Databases 1 February 8th, 2005 10:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.