wood burning stoves 2.0*
The moose likes JDBC and the fly likes These errors are driving me crazy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "These errors are driving me crazy" Watch "These errors are driving me crazy" New topic
Author

These errors are driving me crazy

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Been at this for months and I cant understand why this is happening. I have tried several drivers and I keep getting strange errors and I was hoping someone could help me out. I am trying to develop a applet-servlet-sql connection. I have placed all the classes in a Domino 4.6.7 server the code im using works in Tomcat. I have placed streams throughout the program to catch errors. So when i do the following in the init()
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
myCon = DriverManager.getConnection
("jdbc:microsoft:sqlserver://999.99.99.9:9999;DatabaseName=x;User=x;Password=x");
no errors are thrown. But when I do the following
further in the program in the performTask()
PreparedStatement statement = myCon.prepareStatement(
"INSERT INTO login ([First_Name]) VALUES (?)");
java.lang.NullPointerException:
at t.ServeTwoServlet.performTask(ServeTwoServlet.java:101)
at t.ServeTwoServlet.doPost(ServeTwoServlet.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:278)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
at COM.lotus.go.internal.InternalServletThread.run(InternalServletInvoker.java:396)
at COM.lotus.go.internal.InternalServletInvoker.executeServlet(InternalServletInvoker.java:280)
at COM.lotus.go.internal.InternalServletInvoker.service(InternalServletInvoker.java:202)
at COM.lotus.go.internal.ServletManager.service(ServletManager.java:453)
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

at the point where the code is throwing the error, the connection must have been reset to null(or never set at all). Don't have the rest of your code, so it's hard to help you with that kind of error( if it's not too long, post it ).
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Hey John where is the myCon object declared. Is it in that method, or outside where the performTask method has visibility of that object.
The reason we say this is because it is easy to see that at that last line the myCon variable is set to null.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: These errors are driving me crazy
 
Similar Threads
Read a .xls,.xlsx file format using XSSF
java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
getting error
out of Heap Space
Please Help!!!