区别:
prepareStatement:(为Statement的子类)
conn = DBFactory.getInstance().getImpl().getConnection();
//方式一:(不推荐)
//pstmt = conn.prepareStatement(" update "+tb+" set WDNR=? where "+bh+"=?");
//方式二:
pstmt.setBinaryStream(1, doc.getWDNR(), (int) doc.getStreamSize());
pstmt.setString(2, doc.getWDMC());
returnVal = pstmt.executeUpdate();
______________________________________
Statement:
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//用于加载Driver类(jdbc驱动器)
//registerDriver注册java.sql.DriverManager.registerDriver
Class.forName("org.mariadb.jdbc.Driver").newInstance();
String url = "jdbc:mariadb://192.168.1.100:3306/test?user=root&password=pdcss";
conn = DriverManager.getConnection(url);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);