Question: Name ( print ) : ID: 4 . The following is the login table in the database. Only one tuple in login right now.

Name (print):
ID:
4. The following is the login table in the database. Only one tuple in login right now.
\table[[ID,password],[User3,123456]]
If the following program is executed successfully, list all tuples in the login table, and give the output of the program.
import java.sql.*;
public class JDBCexample {
public static void main(String[] args){
try
f
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:TESTJDBC");/TESTJDBC is the data
source name
Statement st = con.createStatement ;
String str="TESTJDBC";
st.executeUpdate("insert into login values('userl','abcdef')");
st.executeUpdate("insert into login values('user2','123456')");
PreparedStatement stmt=con.prepareStatement("insert into login values(?,'a123456')");
stmt.setString(1, "Tom");
stmt.executeUpdate();
stmt.setString(1, "Jerry");
stmt.executeUpdate();
st.executeUpdate("update login set password='"+str+"' where ID='Jerry"');
ResultSet rs=st.executeQuery("select * from login where password LIKE 'a%"');
String user;
String password;
while (rs.next 0)
{
user-rs.getString(1);
password=rs.getString(2);
System.out.println("ID: "+ user +" password: "+password);
}
rs.close 0 ;
st.executeUpdate("delete from login where password LIKE '%6%"');
st.close();
stmt.close ();
con.close ;
}
catch (Exception e)
i
System.out.println(e);
}
}
a) List tuples of login table in database after the above program is executed successfully. ID password
Name ( print ) : ID: 4 . The following is the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!