mysql__jdbc


有兴趣的,可以加我QQ:245308557


不能运行,需要数据库
package procedures;

import java.sql.*;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import com.mysql.jdbc.*;

public class testProce {

	public static void main(String[] args) {
			getJDBC();

	}
	public static void getJDBC(){

		String sql  = "select * from thaha";
		Connection conn = null;
		Statement s  =null;
		ResultSet rs = null;

		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql" ,"root","123");
			s  = conn.createStatement();
			rs =  s.executeQuery(sql);	
			
			while(rs.next()){
				p(rs.getInt("fuserid")+" ----- ");
				p(rs.getString("fusername")+" ----- ");
				p(rs.getString("fpasswrod")+" ----- ");
				p(rs.getString("fbirday")+" ----- ");
				p(rs.getString("fzhuzhi")+" ----- ");
				p(rs.getString(""));
				p(rs.getString(""));
				p("\n");
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}finally{
			
			try {
				rs.close();
				s.close();
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}			
		}
	}
	public static void p(String s){
		System.out.print(s);
	}
	public static void p(int s){
		System.out.print(s);
	}
	
}

你可能感兴趣的:(mysql,jdbc,Connection)