import java.sql.*;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.net.*;

public class Jdbc1 {

public static void main(String args[]) {
Connection con = null;

try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/trends","root", "trends");
Statement st = con.createStatement();

PreparedStatement ps=null; 
//String sql = "insert into guarantee values (1,'','','','','','','','','',1)";
//ResultSet rs = st.executeQuery("insert into guarantee values (1,'','','','','','','','','',1)");
//ps=con.prepareStatement(sql);
ResultSet rs = st.executeQuery("select * from guarantee");
while(rs.next())
{
System.out.println("Name " + rs.getString(1));
System.out.println("Id " + rs.getString(2));
}
} catch(Exception e) {
e.printStackTrace();
System.out.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
