Created
January 28, 2013 10:20
-
-
Save anonymous/4654434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment