Executing Query from Java
Before this you need to connect to database, refer to this post
Connection conn = null;
try{
DbConnectionProvider
dbConnectionProvider = new DbConnectionProvider();
conn =
dbConnectionProvider.connect();
Statement
stmt=conn.createStatement();
String query = "SELECT NAME,
AGE FROM DETAILS_TABLE";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()){
System.out.println(rs.getString(1));
}}
No comments:
Post a Comment