Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes about upload an image file to mssql database,help me ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "about upload an image file to mssql database,help me !" Watch "about upload an image file to mssql database,help me !" New topic
Author

about upload an image file to mssql database,help me !

junny mei
Greenhorn

Joined: Sep 05, 2001
Posts: 1
I'm using jspsmartupload to upload an image file to mssql database,but when run it appear this error message:
An error occurs : java.lang.NullPointerException 0 file(s) uploaded in the database.
the code :
<%@ page language="java" import="java.sql.*,com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<HTML>
<BODY BGCOLOR="white">
<H1>jspSmartUpload : Sample 4</H1>
<HR>
<%
// Variables
int count=0;
String DriverString,JdbcURL;
Connection conn=null;
java.sql.Statement stmt=null;
java.sql.ResultSet rs=null;
DriverString="sun.jdbc.odbc.JdbcOdbcDriver";
JdbcURL="jdbc dbc:test";
Class.forName(DriverString);
conn=java.sql.DriverManager.getConnection(JdbcURL,"sa","");

// SQL Request
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM TFILES WHERE ID=1");
// if the resultset is not null
if (rs.next()){
// Initialization
mySmartUpload.initialize(pageContext);
// Upload
mySmartUpload.upload();
// upload file in the DB if this file is not missing
if (!mySmartUpload.getFiles().getFile(0).isMissing()){
try {
rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(0).getFileName());
// Add the current file in the DB field
mySmartUpload.getFiles().getFile(0).fileToField(rs,"filel");
// Update
rs.updateRow();
count++;
} catch(Exception e) {
out.println("An error occurs : " + e.toString());
}
}
}
// Display the number of files uploaded
out.println(count + " file(s) uploaded in the database.");
rs.close();
stmt.close();
conn.close();
%>
</BODY>
</HTML>
how can I do ?thanks a lot!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about upload an image file to mssql database,help me !
 
Similar Threads
Servlet becomming slow
Servlet becomming slow
uploading a file using jsp
Uploading File
session problem --======urgent plz======--