标题:Mysql这问题还是不能解决,非连接问题!!!
取消只看楼主
w123012306
Rank: 9Rank: 9Rank: 9
来 自:湖南
等 级:蜘蛛侠
威 望:4
帖 子:307
专家分:1180
注 册:2010-4-22
结帖率:90%
已结贴  问题点数:0 回复次数:0 
Mysql这问题还是不能解决,非连接问题!!!

源代码“

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.DriverManager;
import java.sql.SQLException;
import
import
import

public class BlobDemo1{
   private static  final String Driver="org.gjt.mm.mysql.Driver";
   private static  final String dburl="jdbc:mysql://localhost:3306/justhin";
   private static  final String user="root";
   private static  final String password="admin";
public static void main(String args[]) throws Exception{
     Connection con=null;
     PreparedStatement psmt=null;
    // ResultSet rs=null;
     
     String name="平南";
     String sql="insert into blob1(name,movies) values(?,?)";
     
     Class.forName(Driver);
     con=DriverManager.getConnection(dburl,user,password);
     psmt=con.prepareStatement(sql);
     File f=new File("F:"+File.separator+"20110821482.jpg");
     InputStream input=null;
     input=new FileInputStream(f);
     psmt.setString(1,name);
     psmt.setBinaryStream(2,input,(int)f.length());
     psmt.executeUpdate();
     input.close();
     psmt.close();
     con.close();
  }
}运行报错:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExce
tion: You have an error in your SQL syntax; check the manual that corresponds t
your MySQL server version for the right syntax to use near 'd?e?\"#U?)laj°?
I%?è????íòJ?íe??L??9?\0??hkà@}?7/???\'     {??M?2LkO??÷?D?à??' at line 1
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown So
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at com.mysql.jdbc.Util.getInstance(Util.java:381)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.j
va:1734)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.jav
:2019)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.jav
:1937)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.jav
:1922)
        at BlobDemo1.main(BlobDemo1.java:30)
数据库:     
mysql> desc blob1;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(11)     | NO   | PRI | NULL    | auto_increment |
| name   | varchar(30) | NO   |     |         |                |
| movies | longblob    | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
搜索更多相关主题的帖子: localhost password private 源代码 public 
2011-09-13 20:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-349843-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.371967 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved