wood burning stoves 2.0*
The moose likes JDBC and the fly likes connection error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection error" Watch "connection error" New topic
Author

connection error

panindra nath
Greenhorn

Joined: Jan 23, 2008
Posts: 6
HI,this my servlet code for retreiving contents from the database using ms-access......whenever i launch browser and type in the URL it throws an error


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

i defined a datasource as db2(settings - control panel - administrative tools-odbc-db2)
so what should be the remedy to this problem?

thanks...




import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class test extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{

response.setContentType("text/html");
PrintWriter pw = response.getWriter();
Connection connection=null;


try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc dbc b2");
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
while(rs.next())
{
pw.println(rs.getString(1));
pw.println(rs.getString(2));
pw.println(rs.getString(3));
pw.println();
}
}
catch (Exception e)
{
pw.println(e);
}
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41123
    
  45
Not an answer to this question, but be aware that the JDBC/ODBC bridge is not safe for concurrent access (which is what a servlet environment does, unless you take steps to prevent it).


Ping & DNS - my free Android networking tools app
 
Consider Paul's rocket mass heater.
 
subject: connection error
 
Similar Threads
problem connecting to access
Oracle9i Connectivity thru wsad5.o
simple coding, still not working, may day!!!!
how to delete row in database?, pls help in my coding
servlet program , sql error in coding, helpppp