1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| import java.sql.*;
class NewClass
{
static Connection con=null;
static String connectionURL = null;
private int getUnicode(String arChar)
{
int code=0;
for(int i=0;i<arChar.length();i++)
{
code=arChar.codePointAt(i);
String s = String.valueOf(Character.toChars(code));
System.out.print(s);
}
return code;
}
public static void main(String[] args)
{
NewClass N=new NewClass();
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
connectionURL = "jdbc:oracle:thin:@IP:port:orcl";
System.out.println ("driver etablie");
con=DriverManager.getConnection(connectionURL ,"system","sys");
System.out.println ("connexion base etablie");
Statement s=con.createStatement();
String sql = "select * from employe where num =1 ";
ResultSet rs = s.executeQuery(sql);
System.out.println("no. \tName ");
while (rs.next())
{
System.out.print(rs.getObject("num") + " \t");
System.out.print(rs.getString("nom") + " \t");
N.getUnicode("\n la chaine convertie "+rs.getString("nom"));
}
s.close();
con.close();
} catch(Exception e){e.printStackTrace();}
}
} |
Partager