标签:too print str div public 执行 etc import cut
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Test { public static void main(String[] args) throws ClassNotFoundException, SQLException { //1.加载驱动 Class.forName("oracle.jdbc.driver.OracleDriver"); //2.获得数据库连接 String url="jdbc:oracle:thin:@localhost:1521:orcl"; Connection conn=DriverManager.getConnection(url,"system","toor"); System.out.println("连接成功"); //3.执行sql语句 Statement st=conn.createStatement(); String sql="insert into student values(5,‘nama‘,‘man‘)"; st.execute(sql); System.out.println("插入成功"); st.close(); conn.close(); } }
标签:too print str div public 执行 etc import cut
原文地址:http://www.cnblogs.com/zyy1130/p/6880096.html