?
Solved

please help Java / SQL / DB2

Posted on 2007-04-01
11
Medium Priority
?
434 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:jareddraper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18834269
I just responded to the earlier question... Have a look if it fixes it for you.
0
 

Author Comment

by:jareddraper
ID: 18834282
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
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18834293
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jareddraper
ID: 18834299
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
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18834307
http://www-1.ibm.com/support/docview.wss?uid=swg21114865
check this out.... looks like your unique id is not getting generated properly
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 2000 total points
ID: 18834311
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
 

Author Comment

by:jareddraper
ID: 18834317
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
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18834322
:-) Not a problem... I am also going for some meetings... we will look in to tomorrow... We are quite close to finishing it..
0
 

Author Comment

by:jareddraper
ID: 18837780
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
 

Author Comment

by:jareddraper
ID: 18838929
How would this work as a JSP  form page? that is if you woudn't mind
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18840130
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

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question