Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query not giving expected results

Status
Not open for further replies.

rushtosiva

Programmer
Dec 5, 2000
7
US
Hi All

Here is a part of the java code. There are 2 tables: emp and depts



emp : empno, enpname, deptno

depts: deptno, deptname



I'm using oracle8i. I wrote an sql query where by the output would be the employee number and the department name. When I ran the sql query in sqlplus, I'm getting the expected result. But when the same query is embedded in the java, the resultset does not produce any output.



try{

DriverManager.registerDriver

(new oracle.jdbc.driver.OracleDriver());

System.err.print("Establishing Connection...");

Connection conn = DriverManager.getConnection

("jdbc:eek:racle:eek:ci8:mad:test","system","manager");

System.err.println("Done");

Statement stmt = conn.createStatement();

ResultSet rset = stmt.executeQuery("select name,deptname from emp,depts where emp.deptno=depts.deptno");

while (rset.next()){

System.err.println(rset.getString(1));

System.err.println("and " + rset.getString(2));

}



I'm unclear about this problem.



Any suggestion / recommendation is recommended.



Thanks in Advance

Siva
 
Should

select name,deptname from emp,depts where emp.deptno=depts.deptno

be

select empname,deptname from emp,depts where emp.deptno=depts.deptno

?
 
Hi
Sorry for giving u wrong info. The field is name and not empname.

Thanks for ur effort.
Siva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top