Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

Data source name not found and no default driver specified

 
Himagiri Reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator

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
Pie
Posts: 65109
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
"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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Wow I just glossed over that one. Thanks, Bear.
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 65109
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
"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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic