This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Read data from Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Read data from Oracle" Watch "Read data from Oracle" New topic

Read data from Oracle

Dorj Galaa
Ranch Hand

Joined: May 29, 2001
Posts: 113
I'm trying read data from oracle code is
import java.sql.*;
public class ReadOracleData
public static void main(String args[])
byte[] byte1;
String converted="";
Connection conn = DriverManager.getConnection ("jdbc racle:thin:@host:1521:sid","userr","pswrd");
String Query="select * from province_info";
PreparedStatement st=conn.prepareStatement(Query);
ResultSet Result=st.executeQuery(Query);
while (
catch(Exception e)
but result is
??? ??? ???
??? ??? ???
??? ??? ???
if i change statement
PreparedStatement st=conn.prepareStatement(Query,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
Result is
How to encode?

Senior software engineer
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

your syntax is a bit off. When using PreparedStatement.executeQuery(), you don't need to include the query string as a parameter since it is already declared in the prepareStatement(query) method.
change this
ResultSet Result=st.executeQuery(Query);
ResultSet Result=st.executeQuery();
see how that works.
Dorj Galaa
Ranch Hand

Joined: May 29, 2001
Posts: 113
result is similar.
Oracle table include russian character. if i read russian character occured above problem.
I agree. Here's the link:
subject: Read data from Oracle
Similar Threads
jdbc advanced
I'm posted 1000000000 times tell me idea
strange error while executing an insert statement in MS SQL Server
String Conversion
how do i convert 0x64766972 to dvir