|
|
@ -1,16 +1,18 @@ |
|
|
|
package com.fr.demo; |
|
|
|
package com.fr.demo; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.data.core.db.DBUtils; |
|
|
|
import com.fr.data.core.db.DBUtils; |
|
|
|
import com.fr.web.weblet.DBFormlet; |
|
|
|
|
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import java.sql.SQLException; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.web.session.SessionLocalManager; |
|
|
|
|
|
|
|
import com.fr.web.weblet.DBFormlet; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.sql.Blob; |
|
|
|
import java.sql.Blob; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.DriverManager; |
|
|
|
import java.sql.DriverManager; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.Statement; |
|
|
|
import java.sql.Statement; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
@ -26,7 +28,7 @@ public class NewReadFrmFromDatabase extends DBFormlet { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Form createForm(String reportName) { |
|
|
|
public Form createForm(String reportName) { |
|
|
|
Form form = new Form(); |
|
|
|
Form form = null; |
|
|
|
Connection connection = null; |
|
|
|
Connection connection = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
connection = getConnection(); |
|
|
|
connection = getConnection(); |
|
|
@ -43,20 +45,20 @@ public class NewReadFrmFromDatabase extends DBFormlet { |
|
|
|
return form; |
|
|
|
return form; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
throw SessionLocalManager.createLogPackedException(e); |
|
|
|
}finally { |
|
|
|
}finally { |
|
|
|
DBUtils.closeConnection(connection); |
|
|
|
DBUtils.closeConnection(connection); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return form; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Connection getConnection() throws ClassNotFoundException, SQLException { |
|
|
|
private static Connection getConnection() throws ClassNotFoundException, SQLException { |
|
|
|
// 定义数据连接(根据你实际数据库信息进行修改)
|
|
|
|
// 定义数据连接(根据你实际数据库信息进行修改)
|
|
|
|
String driver = "com.mysql.jdbc.Driver"; |
|
|
|
String driver = "com.mysql.jdbc.Driver"; |
|
|
|
String url = "jdbc:mysql://localhost:3306/test"; |
|
|
|
String url = "jdbc:mysql://localhost:3306/frtest"; |
|
|
|
String user = "root"; |
|
|
|
String user = "root"; |
|
|
|
String pass = "123456"; |
|
|
|
String pass = "root"; |
|
|
|
Class.forName(driver); |
|
|
|
Class.forName(driver); |
|
|
|
Connection conn = DriverManager.getConnection(url, user, pass); |
|
|
|
Connection conn = DriverManager.getConnection(url, user, pass); |
|
|
|
return conn; |
|
|
|
return conn; |
|
|
|