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
Author

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.*;
import java.io.*;
public class ReadOracleData
{
public static void main(String args[])
{
try
{
byte[] byte1;
String converted="";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection ("jdbc racle:thin:@host:1521:sid","userr","pswrd");
(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
String Query="select * from province_info";
PreparedStatement st=conn.prepareStatement(Query);
ResultSet Result=st.executeQuery(Query);
while (Result.next())
{
System.out.println(Result.getString("province_name"));
}
Result.close();
st.close();
conn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
but result is
??? ??? ???
??? ??? ???
??? ??? ???
if i change statement
PreparedStatement st=conn.prepareStatement(Query,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
Result is
0xD185D0B0D0B0D0BD20D0B1D0B0D0BD
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);
to
ResultSet Result=st.executeQuery();
see how that works.
Jamie
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: http://aspose.com/file-tools
 
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