Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:4654434
Created Jan 28, 2013

What would you like to do?
* 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;
conn = DriverManager.getConnection("jdbc:mysql://localhost/mysql?"
+ "user=root&password=onelife");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT host,user,password from user");
while ( {
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