public static void baglanti(){
OracleDataSource ods;
//String driverName = "oracle.jdbc.driver.OracleDriver";
try {
ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@//aaaaaa:2122/XXXXX");
ods.setUser("aaaa");
ods.setPassword("aaaa");
Connection conn=ods.getConnection();
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("SELECT DESCRIPTION FROM example");
while (rs.next()) {
//rs.getString("ID");
System.out.println("DESC : "+rs.getString("1"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I have an error my connection java from to oracle.user name ,password are correct but I couldn't connect to db. Thanks.
DESCRIPTIONbut you try to get the columnsID(commented) and1from theResultSetwhich is why you're getting the error I suppose.StackTracewhich will have column name which is invalid.