啥也不说了,网上软文太多,总结自己写的一些经验总结
1、首先是MySql的连接类
没啥好说的
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MySql {
Connection conn;
public Connection openDB() {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://127.0.0.1:3306/abc?useUnicode=true&characterEncoding=utf-8";
String username = "root";
String password = "123456";
conn = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public boolean close() {
try {
if (conn == null) {
return false;
} else {
conn.close();
return true;
}
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
}
2、然后是用到的Jsp文件
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="UploadBlob.bw" id="form1" name="form1" encType="multipart/form-data" method="post" target="hidden_frame" >
<input type="file" id="file" name="file">
<INPUT type="submit" value="上传文件">
<br>
<font color="red">请上传文件</font>
<iframe name='hidden_frame' id="hidden_frame" style="display: none;"></iframe>
</form>
</body>
</