package com.jnu.cashmanagement.tsa;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.naming.spi.DirStateFactory.Result;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.ResultSetMetaData;
import com.mysql.jdbc.Statement;
public class TestDriverManage {
public static void main(String[] args) throws Exception {
String driverclass = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/bank";
String user = "root";
String password = "123456";
Class.forName(driverclass);
Connection connection = (Connection) DriverManager.getConnection(url, user, password);
System.out.println(connection);
String str = "SELECT * FROM banking";
PreparedStatement ps = connection.prepareStatement(str);
ResultSet resultset = ps.executeQuery();
System.out.println("hello");
ResultSetMetaData rsmd = (ResultSetMetaData) resultset.getMetaData();
while (resultset.next()) {
for (int i = 0; i < rsmd.getColumnCount(); i++) {
String coiunlable = rsmd.getColumnLabel(i + 1);
Object object = resultset.getObject(i + 1);
System.out.println(coiunlable + "=" + object + "");
}
}
resultset.close();
ps.close();
connection.close();
}
}