⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdb.java~21~

📁 编程简单
💻 JAVA~21~
字号:
package myproject;

import java.sql.*;
import java.io.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

public class TestDB {

private static String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
private static String URL = "jdbc:odbc:审计档案数据库";
private static String USER = "sa";
private Connection con = null;

  public TestDB() {
    try{
    BufferedInputStream in = new BufferedInputStream(new FileInputStream("e:/test.doc"));
    File file = new File("e:/test.doc");
    byte[] fileByte= new byte[(int)file.length()];
    in.read(fileByte);
    String str = new String(fileByte);
    Class.forName(DRIVER).newInstance();
    con = DriverManager.getConnection(URL, USER, "");
    Statement sta = con.createStatement();
    String sql  = "insert into testTable values(4,'杨涛',24,"+str+")";
//        String sql  = "insert into testTable values(4,'杨涛',24,'"+"yangtao"+"')";
    int i = sta.executeUpdate(sql);
    System.out.println(i);
    sta.close();
    con.close();
    }
    catch(Exception e){
      System.out.println(e.toString());
    }
  }
  public static void main(String[] args) {
    TestDB testDB1 = new TestDB();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -