Skip to content

Instantly share code, notes, and snippets.

Created January 28, 2013 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4654434 to your computer and use it in GitHub Desktop.
Save anonymous/4654434 to your computer and use it in GitHub Desktop.
/*
* 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