Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

databases and Servlets

Posted on 2002-03-22
2
Medium Priority
?
277 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 60 total points
ID: 6890124
PS:  You should award the points on your abondoned questions or people will not help you.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.
Suggested Courses

963 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