import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class TestDB { public static void main(String args[]) {// connect to the database String url = "jdbc:mysql://localhost/voting"; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Connection conn=null; try { conn = DriverManager.getConnection(url, "root", "9202666672026b"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); System.out.println("couldn't get connection to database"); System.exit(-1); } String query = "select * from imagemapdata;"; Statement stmt; try { stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }