Solved

please help Java / SQL / DB2

Posted on 2007-04-01
11
428 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
diffSum example 4 50
varialbe initialization 11 37
Opening PDF on button click and fill new document 2 47
Configure a Bean in an XML file 4 42
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

839 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