import java.sql.*; class JdbcUrl{ public static void main(String[] args) { try { //URL of the database(ankdb) String connectionURL = "jdbc:mysql://192.168.10.13:3306/ankdb"; // declare a connection by using Connection interface Connection connection = null; // declare object of Statement interface that uses for //executing sql statements. Statement statement = null; // declare a resultset that uses as a table // for output data from the table. ResultSet rs = null; // Load JDBC driver "com.mysql.jdbc.Driver". Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "root", "root"); statement = connection.createStatement(); System.out.println(" Showing row of student table"); // sql query to retrieve values from the specified table. String QueryString = "SELECT * from student"; rs = statement.executeQuery(QueryString); while (rs.next()) { System.out.println(rs.getInt(1) + "\t\t" + rs.getString(2)+"\t\t"+ rs.getString(3)+"\n"); } // close all the connections. rs.close(); statement.close(); connection.close(); } catch (Exception ex) { System.out.println("Unable to connect to batabase."); } } }