File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Data source name not found and no default driver specified Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

Data source name not found and no default driver specified

Himagiri Reddy
Greenhorn

Joined: Oct 04, 2005
Posts: 3
Error is

"Errors are java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

The following program generates the above specified error. I am using jdk1.5 & tomcat5.5. I created correct dsn name. Its working fine with standalone program. I am using win2k Proffessional. Pls suggest me.



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

<%!
Connection con;
Statement st;
ResultSet rs;

%>

<%

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:myne");
st=con.createStatement();
rs=st.executeQuery("select * from employee");
out.println(" Emp Number");
while(rs.next())
{
out.println(" example of getting ");
//out.println("<br>" + rs.getString("id") + " " + rs.getString("empname"));
out.println("<br>" + rs.getInt(1) + " " + rs.getString(2));
}

rs.close();
con.close();
st.close();

} catch(Exception e) { out.println(" Errors are "+ e);}


%>
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Normally I'd say its a problem with the location of the driver JAR, but you're using the JDBC-ODBC bridge. Can you check your JAVA_HOME environment variable and see if it is the Sun JDK? I have a feeling it may not be. The optional Sun classes are only included in the Sun JDKs.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459


Don't do this, it is not thread safe and will cause huge problems in the future. It is always best not to have instance or static variables in JSPs and Servlets.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

"HIMAGIRIJava REDDY",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. And please use mixed case rather than all uppercase.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Wow I just glossed over that one. Thanks, Bear.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Originally posted by HIMAGIRIJava REDDY:
Error is

"Errors are java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

The following program generates the above specified error. I am using jdk1.5 & tomcat5.5. I created correct dsn name. Its working fine with standalone program. I am using win2k Proffessional. Pls suggest me.


That error ALWAYS means your DSN name is incorrect or can't be accessed for some reason (permission). The ODBC part says that the bridge is working.

But that DSN is 100% wrong or cannot be seen by the user account that the server is running as. Make sure you have a system DSN and not a user one.
Himagiri Reddy
Greenhorn

Joined: Oct 04, 2005
Posts: 3
Originally posted by Maximilian Stocker:


That error ALWAYS means your DSN name is incorrect or can't be accessed for some reason (permission). The ODBC part says that the bridge is working.

But that DSN is 100% wrong or cannot be seen by the user account that the server is running as. Make sure you have a system DSN and not a user one.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

"HIMAGIRIREDDY",

My request that you change your display name to conform to JavaRanch standards was not a suggestion.

Read the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious (and please do not use all uppercase).

bear
Forum Bartender
[ October 06, 2005: Message edited by: Bear Bibeault ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Please don't post questions by PM. I usually don't check that email address for two or three days.

JAVA_HOME=c:\jdk1.5. Even I tried the following code also.




Do I have to download any drivers for that? I tried with MySql. It's working fine. For that we downloaded org.gjt.mm.mysql.Driver. Is there anything like that? Now suggest me the solution.


You still are not providing us with enough information.

What is the database? Is it Access, MySQL or something else? If it is MySQL and it works with that Driver, why are you using the JDBC-ODBC bridge? The JAVA_HOME is not your problem.

Dave
Michael Adkins
Greenhorn

Joined: Apr 19, 2011
Posts: 1
To OP:
Have you made sure to add the database to your list of User DSN's? I originally had a database which I made using MS Office Access added to my list of System DSN's, but I was getting the same exact SQL Exception with the same message that you had as well. But, all I did was add the database name to my list of User DSN's and suddenly the problem was resolved. I figured that this might be your problem as well.
Mark Darwin Nacionales
Greenhorn

Joined: Feb 19, 2012
Posts: 2
I know the post was years ago but I felt like answering the question for those who are just experiencing this right now. It took me a while to know the answer to the question so here's the solution:

http://wiki.netbeans.org/FaqSettingHeapSize

Follow the "Running the 32-bit JVM".

All you have to do is find the netbeans.conf in the installation folder of your netbeans and change the directory from something like this:

netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_24"

to this:

netbeans_jdkhome="C:\Program Files (x86)\Java\jdk1.6.0_21"

The problem is netbeans might be running in 64 bit but MS Access only support 32-bit. So doing this would hopefully solve the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data source name not found and no default driver specified
 
Similar Threads
JDBC through Servlet
no dafault driver specified
Connect to access from jsp
Error in JDBC ODBC
connect to Access from jsp