Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package SqlConnection;
- /**
- * Created by Sergio on 6/8/2016.
- */
- import java.sql.*;
- import java.sql.ResultSet;
- public class SqlConnection
- {
- public static void main(String[] args)
- {
- try
- {
- String host = "jdbc:sqlserver://localhost:1433;databaseName=Arkus_Test;user=sa;password=7g8hc9trn";
- Connection con = DriverManager.getConnection(host);
- Statement stmt = con.createStatement();
- String SQL = "SELECT * FROM Mails";
- ResultSet rs = stmt.executeQuery(SQL);
- while (rs.next())
- {
- int id_col = rs.getInt("MailID");
- String correo = rs.getString("Mail");
- String password = rs.getString("Password");
- System.out.println(id_col + " " + correo + " " + password);
- }
- con.close();
- }
- catch (SQLException err)
- {
- System.out.println(err.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement