Solved

databases and Servlets

Posted on 2002-03-22
2
247 Views
Last Modified: 2013-11-24
Guys I have problem with my servlet.Can somebody send me a code of how to send data to a database please. I have tried to do it and gives me a lot of errors. I am able to get data from the database but I cannot send a new data to a database e.g sending new data like the name of a person and all his particulars. Can somebody rescue me
0
Comment
Question by:wbmorapedi
  • 2
2 Comments
 
LVL 4

Expert Comment

by:m_onkey_boy
ID: 6890121
Since you can retrieve data, I'll asume you have the drivers and such correct.  An insert:

PreparedStatement pst = conn.prepareStatement("INSERT into Person (FirstName, LastName, Age) VALUES (?, ?, ?)");
pst.setString(1, "Bob");
pst.setString(2, "Dobbs");
pst.setInt(3, 40);
pst.executeUpdate();

Be sure you are using executeUpdate() as executeQuery() will blow.
0
 
LVL 4

Accepted Solution

by:
m_onkey_boy earned 15 total points
ID: 6890124
PS:  You should award the points on your abondoned questions or people will not help you.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
Java Loop 6 59
Tomcat: Unable to run tomcat service. 2 18
Desingning Refactoring existing code 2 24
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…
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…
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 the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

786 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