jdbc
package javaLearning;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class java01 {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String URL="jdbc:mysql://10.198.2.102/finance_db?useUnicode=true&characterEncoding=utf-8";
String USER="";
String PASSWORD="";
//1.加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2.获得数据库链接
try {
Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);
//3.通过数据库的连接操作数据库,实现增删改查(使用Statement类)
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from finance_proxy_offer");
// 4.处理数据库的返回结果(使用ResultSet类)
while(rs.next()){
System.out.println(rs.getString("wms_area_name"));
}
//关闭资源
rs.close();
st.close();
conn.close();
}finally {
System.out.println();
}
}
}