JDBC

用java语句编写数据库

public  class  JDBCTest{

 

    public static void main(String[] args){

      Class.forName("com.mysql.jdbc.Driver");

      Connection conn=null;

      PreparedStatement ps=null;

      ResultSet rs=null;

      String driver=jdbc:mysql:localhost:8080/Driver;

      String name="root";

      String password="root";

      try{

        conn=DriverManager.getConnection(driver);

        sql="select ename from emp where ename like ?";

        ps=conn.getPrerareStatement(sql);

        ps.setString(1,name);

        rs=ps.exetuQuery();

        while(rs.next){

          rs.getString("sun");

            System.out.println(rs);

         }

        

      

      }

    }

}

posted @ 2018-02-01 09:41  超重语言  阅读(115)  评论(0编辑  收藏  举报