Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*
- public class SimpleJdbc{
- public static void main (String[] args) throws exception{
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println("Driver loaded");
- Connection connection=DriverManager.getConnection("jdbc:mysql://localhost/db","root","root");
- System.out.println("Database connected");
- Statement statement = connection.createStatement();
- ResultSet resultSet=statement.executeQuery("select * from Student");
- while(resultSet.next())
- System.out.println(resultSet.getString(1)+"\t" + resultSet.getInt(2));
- connection.close();
- }
- }
Add Comment
Please, Sign In to add comment