Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- public class testing{
- public static void main(String[] args) throws Exception
- {
- Class.forName("com.mysql.jdbc.Driver");
- java.sql.Connection con= DriverManager.getConnection("jdbc:mysql://localhost/projectjava","interview","password");
- PreparedStatement statement = con.prepareStatement("select * from names");
- ResultSet result = statement.executeQuery();
- while (result.next())
- {
- System.out.println("<html>" +
- "<head><title>Books</title></head>" +
- "<body>" +
- "Hi" +
- "</body>" +
- "</html>");
- System.out.println(result.getString(1) + " " + result.getString(2));
- }
- }
- }
Add Comment
Please, Sign In to add comment