• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Read data from Oracle

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
result is similar.
Oracle table include russian character. if i read russian character occured above problem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic