01
Apr 05

用CFScript做mysql数据库的连接

//连MYSQL数据库
initDriver=createObject("java","java.lang.Class").forName("sun.jdbc.odbc.JdbcOdbcDriver" ).newInstance();
strURL = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=GB2312";
conn=createObject("java","java.sql.DriverManager").getConnection(strURL ,"zhongwen360","");
stmt = conn.createStatement();
query = stmt.executeQuery("SELECT * FROM dictionary WHERE d_chinese like '#show#%' ORDER BY d_chinese");
while(query.next()){
writeoutput(query.getString("dictionary_id"));
}
query.close();

做个备案,大家不防也试,速度是快很多。