Solved

please help Java / SQL / DB2

Posted on 2007-04-01
11
431 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web application structure 18 126
Problem to Alipay 10 91
Why doesn't this text field show up on my Applet frame? 2 39
Notify sent to other threads in Java 9 52
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

740 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