Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: insert statment for Oracle ?

Re: insert statment for Oracle ?

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Sat, 06 Dec 2003 22:52:55 -0800
Message-ID: <1070780006.487012@yasure>


mhk wrote:

> Hi ,
>
> i am having problems in inserting record into oracle database i have the
> following function written for insert but it doesnt work.
>
> can anyone check to see whats wrong. it seems ok to me. my connection is
> also working. i can select records and cannot insert.
>
> Thanks
>
> MY Insert FUNCTION is as below
> *********************************************
>
> public int create_customer(String v1,String v2, String v3, String v4,
> String v5, String v6)
> {
>
> int result = 0 ;
>
> try {
>
> Connection conn =
> DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:global2","test",
> "test");
> String sqlst = "insert into customer values
> ('v1','v2','v3','v4,'v5','v6','v7')";
>
> PreparedStatement pst = conn.prepareStatement(sqlst);
> int v = pst.executeUpdate ();
> conn.close();
> pst.close();
> result = 2 ; // 2 means record added successfully
> } catch (SQLException e)
> {
> System.out.println("There was an error doing the query:");
> }
> return result;
> } // end of method
>
>
> ********************************************************
>

A little more information would be valuable.

For example are you getting an error message?

But in the end I suspect it is doing the insert just fine. But your code does not contain a commit.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Sun Dec 07 2003 - 00:52:55 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US