• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

These errors are driving me crazy

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ).
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic