Images and MS Access

hey i used blob field to store a image. However a sql syntax error is caused:

Syntax error in field destination.

Do MS Access supportBLOBfrield??

I used the following code:

import java.io.*;

import java.sql.*;

import java.util.Properties;

import java.awt.*;

import javax.swing.*;

publicclass ImageDemo{

publicstaticvoid main(String argv[]){

try{

//String url="jdbc:access:/c:/";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

String filename ="c:/imagedatabase.mdb";

String database ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";

database+= filename.trim() +";DriverID=22;READONLY=true}";// add on to the end

//Properties properties=new Properties();

Connection connection = DriverManager.getConnection(database,"Admin","abc123");

System.out.println("hello");

Statement stmt = connection.createStatement();

//stmt.execute("create database if not exists imagedatabase;");

connection.setCatalog("imagedatabase.mdb");

System.out.println("hello");

stmt.execute("create table imagetable (imageid int,IMAGE_DATA blob);");

//FileInputStream in;

File file=new File("c:/pic.jpg");

try{FileInputStream in=new FileInputStream(file);

System.out.println((int)file.length());

PreparedStatement ps=connection.prepareStatement("insert into imagetable (imageid,IMAGE_DATA) values(?,?)");

ps.setInt(1,1234);

ps.setBinaryStream(2,in,(int)file.length());

ps.execute();

ps.close();

}

catch(Exception e){System.out.println(e);}

ResultSet rs =stmt.executeQuery("select IMAGE_DATA from imagetable where imageid=1234");

byte[] imgbytes=null;

if(rs.next()){

imgbytes=rs.getBytes(1);

}

rs.close();

stmt.close();

connection.close();

if(imgbytes!=null){

JFrame fr =new JFrame();

fr.setTitle("Simple Demo for Load Image from MS Access");

Image image = fr.getToolkit().createImage(imgbytes);

fr.getContentPane().add(new PaintPanel(image));

fr.setSize(200,400);

fr.setVisible(true);

Thread.sleep(10000);

System.exit(0);

}

}

catch( SQLException sqle )

{

do

{

System.out.println(sqle.getMessage());

System.out.println("Error Code:"+sqle.getErrorCode());

System.out.println("SQL State:"+sqle.getSQLState());

sqle.printStackTrace();

}while((sqle=sqle.getNextException())!=null);

}

catch( Exception e )

{

System.out.println(e.getMessage());

e.printStackTrace();

}

}

}

class PaintPanelextends JPanel{

private Image image;

public PaintPanel(Image image){

this.image = image;

}

publicvoid paintComponent(Graphics g){

super.paintComponent(g);

g.drawImage(image, 0, 0,this);

}

}

PLZ help me

[5475 byte] By [dadabaea] at [2007-10-3 4:06:40]
# 1
can you post the error message with the stack trace?
LRMKa at 2007-7-14 22:06:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...