// Connect to the database
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://server:1433;DatabaseName=test","sa","");
// SQL Requestconn=DriverManager.getConnection(sconnstr,"sa","");
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT * FROM TFILES WHERE ID=3");
if (rs.next()){
// Connect to the database
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://server:1433;DatabaseName=test","sa","");
// SQL Request
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM TFILES where id=3");
// if the resultset is not null
if (rs.next()){
String FileName=rs.getString("FileName");
// Initialization
mySmartUpload.initialize(pageContext);
mySmartUpload.setTotalMaxFileSize(200000);
// Download field
mySmartUpload.downloadField(rs,"FILE","application/x-msdownload", "2.txt");