PR 18 Exercise
PR 18 Exercise
PR 18 Exercise
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
ResultSet rs=st.executeQuery(s1);
rs=st.getResultSet();
while(rs.next())
OUTPUT:
import java.sql.*;
try {
Connection c;
Statement st = c.createStatement();
st.execute(str);
st.close();
c.close();
} catch (Exception e) {
e.printStackTrace();
}
import java.sql.*;
class jdbcDemo{
try {
Connection c;
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Driver Loaded");
Statement st = c.createStatement();
ResultSet rs = st.executeQuery(str);
while(rs.next()){
text = text+rs.getInt(1)+"\t"+rs.getString(2)+"\n";
System.out.println(text);
st.close();
c.close();
} catch (Exception e) {
e.printStackTrace();
}
}