Solved

please help Java / SQL / DB2

Posted on 2007-04-01
11
423 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 52
java set up 1 48
base64 decode encode 12 100
Java asynchronous logging 4 35
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now