Java 如何启用";“加载数据本地填充”;在mysql JDBC中?
我正在尝试使用JDBC通过Java程序将数据加载到表中。 我已经完成了以下步骤: sudo nano/etc/mysql/my.cnf 然后添加: [mysqld]本地infle=ON [mysql]本地infle=ON 运行此程序时: 代码:Java 如何启用";“加载数据本地填充”;在mysql JDBC中?,java,mysql,jdbc,Java,Mysql,Jdbc,我正在尝试使用JDBC通过Java程序将数据加载到表中。 我已经完成了以下步骤: sudo nano/etc/mysql/my.cnf 然后添加: [mysqld]本地infle=ON [mysql]本地infle=ON 运行此程序时: 代码: Statement statement = con.createStatement();String sql="Create table tbl_user_analysis (Country varchar(10),State Varchar(20))"
Statement statement = con.createStatement();String sql="Create table tbl_user_analysis (Country varchar(10),State Varchar(20))";
statement.executeUpdate("drop table tbl_user_analysis");
statement.executeUpdate(sql);
statement.executeUpdate("load data local infile /home/Asus/workspace/example/xyz into table tbl_user_analysis fields terminated by '\\t' ");
但我有一个例外:
线程“main”中出现异常
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您有一个
SQL语法错误;检查与您的产品相对应的手册
MySQL服务器版本,以便在附近使用正确的语法
'/home/Asus/workspace/example/xyz进入表
第1行的tbl_用户分析
sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
在
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
在
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:526)
位于com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
com.mysql.jdbc.Util.getInstance(Util.java:386)位于
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)位于
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)位于
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)位于
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)位于
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)位于
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2788)位于
com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1816)
在
com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1730)
在example1.example.main(example.java:281)
你重启mysqld了吗?@kostja是的,我也重启了,但我得到了相同的例外我得到了它是一个语法错误(我忘记使用“单引号”):将数据本地填充“/home/Asus/workspace/example/xyz”加载到以“\\t”结尾的表tbl_user_分析字段中