public void getDatabaseConnectionExample() {
Connection connection = null;
try {
connection = Platform.getOperationalDS().getConnection();
String sql = "select usr_login from usr";
PreparedStatement preparedStatement = null;
preparedStatement = connection.prepareStatement(sql);
ResultSet rs = preparedStatement.executeQuery();
while(rs.next()){
System.out.println("User Login :: " + rs.getString(1));
}
} catch (Exception e) {
System.out.println("Exception occured while reading user details " + e);
} finally {
try {
connection.close();
} catch (Exception e) {
System.out.println("Exception while closing connection : " + e);
}
}
}
Happy Learning!!!
Connection connection = null;
try {
connection = Platform.getOperationalDS().getConnection();
String sql = "select usr_login from usr";
PreparedStatement preparedStatement = null;
preparedStatement = connection.prepareStatement(sql);
ResultSet rs = preparedStatement.executeQuery();
while(rs.next()){
System.out.println("User Login :: " + rs.getString(1));
}
} catch (Exception e) {
System.out.println("Exception occured while reading user details " + e);
} finally {
try {
connection.close();
} catch (Exception e) {
System.out.println("Exception while closing connection : " + e);
}
}
}
Happy Learning!!!
I just want to thank you for sharing your information and your site or blog this is simple but nice Information I’ve ever seen i like it i learn something today. Email Marketing Jobs
ReplyDelete