package com.company;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
/**
* Created by ttc on 16-10-27.
*/
public class 更新
{
public static void UpdateDept(int deptno, String DeptName) throws ClassNotFoundException, SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
String st = "jdbc:oracle:thin:@localhost:1521:orcl";
Connection ct = DriverManager.getConnection(st, "scott", "l123456");
Statement sm = ct.createStatement();
String stSQL = "update dept set dname='"+DeptName+"' where deptno="+deptno;
sm.executeUpdate(stSQL);
sm.close();
ct.close();
}
public static void main(String[] args) throws SQLException, ClassNotFoundException
{
UpdateDept(90,"dssda");
}
}
java
最新推荐文章于 2024-05-21 17:32:36 发布