Solved

databases and Servlets

Posted on 2002-03-22
2
225 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
Comment Utility
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
Comment Utility
PS:  You should award the points on your abondoned questions or people will not help you.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

743 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

15 Experts available now in Live!

Get 1:1 Help Now