Statement st = conn.createStatement(); st.executeUpdate("insert into User(loginname,password) values('"+request.getParameter("lname")+"','"+request.getParameter("pass")+"')");
st.close(); conn.close(); } catch(Exception e) { out.println("Exception Has Been Caught <br>" + e); } out.println("</body>"); out.println("</html>"); } }
The error which i get is:
Exception Has Been Caught java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I tried the same connection in a simple java program and there is no problem with it. Is there some thing to be added while using in Servlet. I am using TOMCAT server.
Archana S
Chandra Sekhar
Ranch Hand
Joined: Sep 26, 2003
Posts: 90
posted
0
Check you have created a DSN with the name "mail".Cross check your data source name in your ODBC Datasource in your OS
As another suggestion, I highly highly recommend that you move the JDBC code from the Servlet an place it in a plain old Java object that the Servlet could call.
By having JDBC code in your Servlet, you are tightly coupling JDBC with your Servlet. Unless this is a class homework or one-off quick test. You would not want the code you currently have in production.
Hi Chandrasekhar S I dont get the meaning of "Cross check your data source name in your ODBC Datasource in your OS ". Can you please explain me abt it.
Hi Praful Thakare i have placed the classes111.zip file. And still it is not working. Should i unzup the contents in it.
Hi Mark Spritzler Cnd you just tell how to call a java object from a servlet. Please. I think this will work as my ordinary java file of connecting the database works correctly.
Regards, Archana S
Praful Thakare
Ranch Hand
Joined: Feb 10, 2001
Posts: 613
posted
0
Hi, Write Java File With Following Code.(This is just for testing puropose..you much use different approch for production).
No Need to unzip that zip file,just check the logs after you execute following program.and lets us know the sysouts
[ August 27, 2004: Message edited by: Praful Thakare ]
Well a Servlet is Java code right? So to call a plain old Java object, you just create an instance of it in your Servlet, then call one method that will bo your Database stuff for you and return the information that you want, that you then put into the Response object to send back to the client in any way you wish.
Good Luck
Mark
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.