public
anonymous / gist:4654434
Created

  • Download Gist
gistfile1.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.swing.JFrame;
import javax.swing.JPanel;
 
/**
*
* @author HP Pavilion
*/
public class JavaApplication3 {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Connection conn = null;
Statement stmt = null;
 
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/mysql?"
+ "user=root&password=onelife");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT host,user,password from user");
while (rs.next()) {
String host = rs.getString("host");
String user = rs.getString("user");
String pass = rs.getString("password");
System.out.println("Host:\t\t" + host);
System.out.println("Usert:\t\t" + user);
System.out.println("Password:\t" + pass);
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.