我正在开发一个简单的 jdbc 程序。如何在 jdbc 程序中使用扩展的 dll 功能。
这是我的代码:
import java.sql.*;
public class jdbc2
{
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/somesh";
// Database credentials
static final String USER = "root";
static final String PASS = "";
public static void main(String[] args)
{
Connection conn = null;
Statement stmt = null;
try{
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
// System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
System.out.println("Connecting to database...");
//STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql = " select id,image from images1 ";
ResultSet rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while(rs.next())
{
//Retrieve by column name
System.out.println("\n");
int no = rs.getInt("id");
System.out.print("\t USER_I_ID: " +no);
/*String std_name = rs.getString("name");
System.out.print(" \t First_name : " + std_name);
String std_course = rs.getString("course");
System.out.print(" \t course : " + std_course);*/
Blob std_image = rs.getBlob("image");
System.out.print(" \t std_images : SS" + std_image);
}
}
catch(SQLException se)
{
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e)
{
//Handle errors for Class.forName
e.printStackTrace();
}finally
{
//finally block used to close resources
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}// nothing we can do
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end catch try
}//end finally
}//end main
}//end FirstExample
现在我使用的dll函数是:
int AddFpUser ( BOOL bSorC, BYTE FacID, int nTmlSize, BYTE *pTemplate, const char *UserName, const char *UserID, BYTE GroupID, BYTE FingerID, BYTE UserType ).
所以请使用上面程序的这个功能。该函数定义包含存储图像..所以请给出答案。感谢您的帮助