这是我尝试插入远程数据库表的 java 代码。
session.connect();
Channel channel = session.openChannel("exec");
String query = "INSERT INTO table_name
(id,serialno,userid,checktime,checktype,eventType)
VALUES(502,1011,0078,'2017-04-17 17:27:51',6,23)";
((ChannelExec) channel).setCommand("mysql -uuser -ppwd -h localhost -e'" +
query + "' database_name");
InputStream in = channel.getInputStream();
channel.connect();
我使用相同的代码来执行“select *”查询,而不是“插入查询”它完美地执行并且我得到了输出。但在这种情况下,它没有。请帮我找到解决方案。