it's simple only follow5 simple steps:1) create a class object for Driver Class
Class.forName("com.mysql.jdbc.Driver");2) create a connection object
Connection con=DriverManager.getConnection("jdbc:mysql://localhose/dbname","username","password");3)create statement object
ststement st=con.createStatement();4)write sql query
String sql="........ ";5)run query by
st.executeQuery(sql);