import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBUtil {
public static void main(String[] args) throws Exception{
//1.加载驱动
Class.forName("com.mysql.jdbc.Driver");
//Class.forName("oracle.jdbc.driver.OracleDriver");
//2.获取连接
Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/admin", "root", "123456");
//创建statement或者preparedStatement对象来执行sql
//Statement s = conn.createStatement();
//ResultSet rs = s.executeQuery("select * from lf_admin");
PreparedStatement p = conn.prepareStatement("update lf_admin set lf_admin_username=?");
p.setString(1, "admin");
p.execute();//修改增加删除
// p.executeQuery();//查询
/*while(rs.next()){
String name = rs.getString("lf_admin_username");
System.out.println(name);
}*/
}
}
最近在整理一些资源工具,放在网站分享 http://tools.maqway.com
欢迎关注公众号:麻雀唯伊 , 不定时更新资源文章,生活优惠,或许有你想看的