Retrieve value from database through JDBC statement.

puneet kumar
puneet kumar used Ask the Experts™
HI Team ,

I am retrieving value from database through JDBC statement  my plsql query is below -

Select * from A union Select * from B.

but when i am retrieving value through JDBC statements its give null . when i am individually running query like Select * from A without using Union  its working fine and giving results but when i am using 2 query via Union its give Null. Please tell me where i m wrong .
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Condition for SQL UNION is that  tables must match number and names of columns. You are using "select *" for each one, then, Table B is exactly similar than Table A?
puneet kumarSenior Software Engineer


I am using the query as below per result is same as above -

String sqlString = Select Employee_ID , Employee_Code  from A union Select Employee_ID,Employee_Code  from B

its giving null when i am executing below -

result = stat.executeQuery(sqlString);

But if I am running individually one by one its giving result . please let  me know where i am wrong.
You shouldn't have problems. Could you put more detail of the java code?
Senior Software Engineer
i found my solution one extra ; gives the problem .when i remove extra ; its working perfectly . Thank You.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial