/**
*
*/
package mysql;
import java.sql.*;
/**
* @author princeteja *
*/
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/menagerie","root", "database" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from pet");
while(rs.next()){
System.out.println(rs.getString(1));
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
st.close();
con.close();
}
}
}