please help Java / SQL / DB2

Any help with this topic would be great I closed it a little soon I guess

http://www.experts-exchange.com/Database/DB2/Q_22483986.html
jareddraperAsked:
Who is Participating?
 
KuldeepchaturvediCommented:
Here is another 1
SQLCODE -803 SQLSTATE 23505
      Duplicate key on insert or update



the best thing is to drop and recreate the table and see if it starts working...
our java code is working becuase its going to the database.. so thats a good thing
0
 
KuldeepchaturvediCommented:
I just responded to the earlier question... Have a look if it fixes it for you.
0
 
jareddraperAuthor Commented:
The ps.executeUpdate(); worked I was able to figure that part out. I am still however having issues with my insert statement here is what I have

PreparedStatement ps = conn.prepareStatement("insert into DB2INST1.DLDATA values (?,?,?,?,?,?,?)");
                  ps.setString(1,rq.getParameter("CompanyID"));
                  ps.setString(2,rq.getParameter("License"));
                  ps.setString(3,rq.getParameter("FirstName"));
                  ps.setString(4,rq.getParameter("LastName"));
                  ps.setString(5,rq.getParameter("Address"));
                  ps.setString(6,rq.getParameter("City"));
                  ps.setString(7,rq.getParameter("State"));
                  ps.executeUpdate();

That fail but I can run this from a sql command line and it works

INSERT INTO DLDATA (COMPANYID, LICENSE, FIRSTNAME, LASTNAME, ADDRESS,
  CITY, STATE)
  VALUES ('AR1', '123456', 'Test', 'User', '10757 south home drive',
    'SLC', 'UT')

The ID colum is a generated integer and the middlename colum can be null so I didn't it but i should I can

Thank you again I am so close to completing my first java servlet and having it work I can taste it
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
KuldeepchaturvediCommented:
okay lets change our insert statement to be.. as

conn.prepareStatement("insert into DB2INST1.DLDATA(COMPANYID, LICENSE, FIRSTNAME, LASTNAME, ADDRESS,
  CITY, STATE)
 values (?,?,?,?,?,?,?)");

& then try it... if it does not work, show me the error trace and we can have a look at it...

0
 
jareddraperAuthor Commented:
ok here is what I get

[4/1/07 21:47:33:757 MDT] 00000030 SystemErr     R com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 1;DB2INST1.DLDATA
      at com.ibm.db2.jcc.c.fg.d(fg.java:1340)
      at com.ibm.db2.jcc.b.gb.k(gb.java:351)
      at com.ibm.db2.jcc.b.gb.a(gb.java:60)
      at com.ibm.db2.jcc.b.w.a(w.java:52)
      at com.ibm.db2.jcc.b.wb.c(wb.java:213)
      at com.ibm.db2.jcc.c.gg.ab(gg.java:1779)
      at com.ibm.db2.jcc.c.gg.d(gg.java:2324)
      at com.ibm.db2.jcc.c.gg.W(gg.java:457)
      at com.ibm.db2.jcc.c.gg.executeUpdate(gg.java:440)
      at com.arkona.Simple.doGet(Simple.java:48)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
      at com.ibm.ws.webcontainer.extension.InvokerExtensionProcessor.handleRequest(InvokerExtensionProcessor.java:195)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
      at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
      at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

[4/1/07 21:47:33:757 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.c.fg.d(fg.java:1340)
[4/1/07 21:47:33:757 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.b.gb.k(gb.java:351)
[4/1/07 21:47:33:757 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.b.gb.a(gb.java:60)
[4/1/07 21:47:33:758 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.b.w.a(w.java:52)
[4/1/07 21:47:33:758 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.b.wb.c(wb.java:213)
[4/1/07 21:47:33:758 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.c.gg.ab(gg.java:1779)
[4/1/07 21:47:33:758 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.c.gg.d(gg.java:2324)
[4/1/07 21:47:33:758 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.c.gg.W(gg.java:457)
[4/1/07 21:47:33:759 MDT] 00000030 SystemErr     R       at com.ibm.db2.jcc.c.gg.executeUpdate(gg.java:440)
[4/1/07 21:47:33:759 MDT] 00000030 SystemErr     R       at com.arkona.Simple.doGet(Simple.java:48)
[4/1/07 21:47:33:759 MDT] 00000030 SystemErr     R       at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
[4/1/07 21:47:33:759 MDT] 00000030 SystemErr     R       at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[4/1/07 21:47:33:760 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
[4/1/07 21:47:33:760 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
[4/1/07 21:47:33:760 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.extension.InvokerExtensionProcessor.handleRequest(InvokerExtensionProcessor.java:195)
[4/1/07 21:47:33:760 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
[4/1/07 21:47:33:760 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
[4/1/07 21:47:33:761 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
[4/1/07 21:47:33:761 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
[4/1/07 21:47:33:761 MDT] 00000030 SystemErr     R       at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
[4/1/07 21:47:33:761 MDT] 00000030 SystemErr     R       at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
[4/1/07 21:47:33:761 MDT] 00000030 SystemErr     R       at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
[4/1/07 21:47:33:762 MDT] 00000030 SystemErr     R       at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
[4/1/07 21:47:33:762 MDT] 00000030 SystemErr     R       at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201)
[4/1/07 21:47:33:762 MDT] 00000030 SystemErr     R       at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
[4/1/07 21:47:33:762 MDT] 00000030 SystemErr     R       at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
[4/1/07 21:47:33:763 MDT] 00000030 SystemErr     R       at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601)
[4/1/07 21:47:33:763 MDT] 00000030 SystemErr     R       at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
[4/1/07 21:47:33:763 MDT] 00000030 SystemErr     R       at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
[4/1/07 21:47:33:763 MDT] 00000030 SystemErr     R       at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
0
 
KuldeepchaturvediCommented:
http://www-1.ibm.com/support/docview.wss?uid=swg21114865
check this out.... looks like your unique id is not getting generated properly
0
 
jareddraperAuthor Commented:
ok great I will give this a try first thing in the morning. Again thank you for all your help on this. Who knows maybe one I will understand a least a small part of this. Its a lot different then just being a linux systems engineer. I will leave this open until tomorrow after I try it
0
 
KuldeepchaturvediCommented:
:-) Not a problem... I am also going for some meetings... we will look in to tomorrow... We are quite close to finishing it..
0
 
jareddraperAuthor Commented:
Everything is working, I was able to correct the issue with your help on this and I now have a working servlet. This has a great learning for me and I understand how a basic servlet like this works now. Thank you so much help it has been great.
0
 
jareddraperAuthor Commented:
How would this work as a JSP  form page? that is if you woudn't mind
0
 
KuldeepchaturvediCommented:
the basic concept is pretty much the same...
ideally, your jsp should be displaying a form and then the form should be submitted to this servlet..

the thumb rule is that any UI related work should be in jsp & any core/business related work should be in servlet...

also it is always a good idea to create a separate bean for database connections and use it throughout the project...... so we do not have to duplicate the code everywhere in the system.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.