Two Laptop Bag*
The moose likes JDBC and the fly likes JDBC Error related to Tomcat and Oracle 10g Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Error related to Tomcat and Oracle 10g" Watch "JDBC Error related to Tomcat and Oracle 10g" New topic
Author

JDBC Error related to Tomcat and Oracle 10g

Nelo Angelo
Ranch Hand

Joined: Jul 25, 2011
Posts: 44

Hello,

I am unable to perform database connectivity through JSP. I am receiving the following error when i try to run my code:
Error java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

==============
SOFTWARE DETAILS
==============

JAVA VERSION: j2sdk1.4.1
Database: Oracle 10g Express Edition
Tomcat Version: Tomcat 5.5

=======================
ENVIRONMENT VARIABLE ENTRIES
=======================

CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 5.5\

CLASSPATH: .;C:\mysql-connector-java-5.0.8\mysql-connector-java-5.0.8-bin.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;C:\JSDK2.0\lib\jsdk.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip

JAVA_HOME: C:\j2sdk1.4.1\bin


==========
SOURCE CODE
==========
FileName: getSugaInsert.jsp

<%@ page import="java.sql.* "%>
<%
String name="", email="";

if(name!=null)
{
Connection conn;
Statement stmt;

try
{
name=request.getParameter("name");
email=request.getParameter("email");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbcdbc:CMS","system","password");
stmt=conn.createStatement();

stmt.execute("insert into Tester values ('"+name+"','"+email+"')");
out.println("Record Inserted");
}
catch(Exception e)
{
out.println("Error "+e);
}
}
else
{
%>
<HTML>
<HEAD>
<TITLE>INSERTING DATA INTO TABLE</TITLE>
</HEAD>

<BODY>
<FORM ACTION="getSugaInsert.jsp" METHOD=post>
NAME: <INPUT TYPE=test NAME="name" />
EMAIL: <INPUT TYPE=text NAME="email" />
<INPUT TYPE=submit VALUE="insert" />
</FORM>
</BODY>
</HTML>
<%
}
%>

=========================================================================

Please inform me if i am missing any details.


I love java but she hates me... :'(
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi,

is system DSN name is defined in Windows?

Thanks


The important thing is not to stop questioning.Curiosity has its own reason for existing.
Nelo Angelo
Ranch Hand

Joined: Jul 25, 2011
Posts: 44

Hey,

Sry, didn't get you completely. I am new to java so I am not quite familiar with the terms used .

Anyways, if this help:

I have created this DSN.

Its a UserDSN

Name: CMS
Driver: Oracle in XE

The OS is Windows (if thats what you were asking. )
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

ok.
that's what I'm asking..

In don't know whether this will be the appropriate solution but try this one also.
instead of using userDSN ,delete it and create a systemDSN and try to connect once.

Thanks
Nelo Angelo
Ranch Hand

Joined: Jul 25, 2011
Posts: 44

Thanks man. The problem is now resolved. However, I had to bring about a few extra modifications to make it work.

============
CHANGES DONE:
============

UserDSN to SystemDSN,

Downloaded "ojdbc14.jar" and placed in Tomcat's common\lib,

Changed the driver to "oracle.jdbc.driver.OracleDriver",

Amendments done to the CLASSPATH,

Corrected a few logical errors (present in the starting lines).


=================================

The problem is rosolved (for now ). This is a pretty helpful place for java beginners. I got the idea for downloading the jar file through other topics being discussed in the forum. Anyways, thanks again for helping me out.
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Ok..great

from your code written here I thought you are using jdbcdbc drivers(Type1 driver),
so I didn't ask you about the jar and setting it up in classpath.

This is one of the type of driver for DB connections.

Thanks.
Nelo Angelo
Ranch Hand

Joined: Jul 25, 2011
Posts: 44

Is there any way to make it work without installing new drivers?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC Error related to Tomcat and Oracle 10g
 
Similar Threads
Connector/J driver error
Compilation problem in servlets
Tomcat and Oracle, will i transfer any file?
servlets
Unable to execute insertion!