This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39544
    
  27
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 - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connection error
 
Similar Threads
problem connecting to access
servlet program , sql error in coding, helpppp
simple coding, still not working, may day!!!!
how to delete row in database?, pls help in my coding
Oracle9i Connectivity thru wsad5.o