Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2007

Tip: Looking for answers? Try searching our database.

I want corect code for deletind data from database(SQL)

Thread view: 
amit.chhodhary@gmail.com - 21 Nov 2007 09:08 GMT
selectedName = request.getParameter("Combo Box");

statement.executeUpdate("delete ID,PHONENAME from PHONE where
ID=(select ID from PHONE WHERE PHONENAME= +selectedName ) " );

I want corect code for deletind data from database(SQL);
Lew - 21 Nov 2007 13:51 GMT
> selectedName = request.getParameter("Combo Box");
>
> statement.executeUpdate("delete ID,PHONENAME from PHONE where
> ID=(select ID from PHONE WHERE PHONENAME= +selectedName ) " );
>
> I want corect code for deletind data from database(SQL);

Snippet:

private static final String SQL =
"delete ID,PHONENAME from PHONE where PHONENAME = ?";
Connection cxn = DriverManager.getConnection( dbUrl );
PreparedStatement ps = cxn.prepareStatement( SQL );
int nRows = ps.executeUpdate();

Program structure and exception handling are obviously omitted.

You should consider being more detailed and complete with your questions.

Signature

Lew

Arne Vajhøj - 21 Nov 2007 21:00 GMT
>> selectedName = request.getParameter("Combo Box");
>>
[quoted text clipped - 12 lines]
>
> Program structure and exception handling are obviously omitted.

I think I would use:

private static final String SQL = "delete from PHONE where PHONENAME = ?";
Connection cxn = DriverManager.getConnection( dbUrl );
PreparedStatement ps = cxn.prepareStatement( SQL );
ps.setString(1, selectedName);
int nRows = ps.executeUpdate();

I think you would too.

Arne
Lew - 22 Nov 2007 02:08 GMT
> I think I would use:
>
[quoted text clipped - 5 lines]
>
> I think you would too.

Crap.  You're right.  I should've looked at the SQL more closely.

I was careless.  Sorry.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.