zoukankan      html  css  js  c++  java
  • 数据库02

    这里只演示java-数据库的基本操作,在此基础上,再随便找本相关的参考书即可完成数据库其他基本操作。。。

    package org.lxh.demo17.connectdemo;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;

    public class ResultSetDemo01 {
      public static final String DBDRIVER = "com.mysql.jdbc.Driver";
      public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
      public static final String DBUSER = "root";
      public static final String DBPASS = "xyzk123";
      public static void main(String[] args) throws Exception{
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String sql = "SELECT empno,ename,job FROM t_dept";
        Class.forName(DBDRIVER);
        conn = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
        stmt = conn.createStatement();
        rs = stmt.executeQuery(sql);
        while(rs.next()){
          int empno = rs.getInt("empno");
          String ename = rs.getString("ename");
          String job = rs.getString("job");

          System.out.println("编号" + empno + ";");
          System.out.println("姓名" + ename + ";");
          System.out.println("职业" + job + ";");
          System.out.println(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,");
        }
        rs.close();
        stmt.close();
        conn.close();
      }

    }

  • 相关阅读:
    windows XP 下的DTRACE 跟踪 学习
    copy to tmp table
    快麦
    SQL SERVER BOOK
    启锐电子面单驱动
    grep---find
    mysql中kill掉所有锁表的进程
    sqlserverinternals.com
    从顺序随机I/O原理来讨论MYSQL MRR NLJ BNL BKA
    解析MYSQL BINLOG二进制格式
  • 原文地址:https://www.cnblogs.com/XuGuobao/p/7050743.html
Copyright © 2011-2022 走看看