Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*import javax.servlet.*;
- import javax.servlet.http.*; */
- import java.sql.*;
- import java.sql.Connection.*;
- public class ralph {
- public static void main(String[] args)
- {
- javax.swing.JOptionPane.showMessageDialog(null,"this is a test!!");
- Connect();
- }
- static void Connect()
- {
- Connection con = null;
- Statement stm;
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- }
- catch(java.lang.ClassNotFoundException e)
- {
- System.err.print("ClassNotFoundException: ");
- System.err.println(e.getMessage());
- javax.swing.JOptionPane.showMessageDialog(null, e.getMessage());
- }
- try
- {
- con=DriverManager.getConnection("Jdbc:mysql://localhost:3306/ralph?"+"user=root&password=roots");
- stm=con.createStatement();
- String strQry="select * from user_acc";
- ResultSet rs = stm.executeQuery(strQry);
- while (rs.next())
- {
- System.out.println(rs.getString(1) + rs.getString(2) + rs.getString(3));
- }
- con.close();
- }
- catch(Exception e)
- {
- System.out.println(e);
- javax.swing.JOptionPane.showMessageDialog(null, e.getMessage());
- }
- }
- }
Add Comment
Please, Sign In to add comment