Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

query syntax

I was going through following link.

http://www.roseindia.net/tutorial/java/poi/insertExcelFileData.html

I have not understtod below query syntax

int k=stat.executeUpdate("insert into login(username,password) value('"+username+"','"+password+"')");

>>login(username,password)
 is login is the name of the table with columns names username,password in the paranthesis?

I need to build select query similar way.

 Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

executeUpdate I got as 1 but when I went to toad to check the record it is not there
int k=stat.executeUpdate("insert into login(username,password) value('"+username+"','"+password+"')");



Do I need to give any commit statement in the java code explicitly. Please advise
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

>>Do I need to give any commit statement in the java code explicitly.

It is good coding practice to physically commit or rollback and not rely on the 'default' action.

>> I got as 1

I don't know what this means. If it is a return code, does a 1 mean successful?  Remember I'm not a Java guy.
Avatar of gudii9

ASKER

I was checking below command

select count(*) into <variable_1> from dual where exists (select null from XYX_Table where col1=<variable_2> and col2=<variable_3>);


I am getting 1 even when record is there or not from java program.

And getting 0 from toad always. Please advise
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the "1" (or "0") is normally the number of rows affected.
Avatar of gudii9

ASKER

>>whenever you use the count() only the field in the select clause, it will always return a single row.

can you please elaborate on this. I am not clear on this




I have gone through the link
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:19398056075583

I have not clearly understood about bind variables and their significance with prepared statements

>>>

Followup   June 8, 2004 - 3pm Central time zone:

I was pointing out that in this sequence of code:

     39     PreparedStatement pstat =
     40     conn.prepareStatement
     41     ("Select this is not really SQL now is it?" );
     42
     43     pstat.setString( 1, ename_like );
     44     ResultSet rset = pstat.executeQuery();
     45



the statement is not parsed by the server, in fact not sent to the server, until line 44 -- so we
do in fact have access to the bind variable values at parse time.



Please advise
>>I have not clearly understood about bind variables and their significance with prepared statements

Using bind variables reduces the risk of SQL Injection and Hard parsing.  Don't try to understand the entire thread since it is talking about bind variable peeking.  That isn't what I was eanting you to take from it.  Just the Bind variables themselves.