kettle学习之连接数据库资源库执行sql时报错

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/chenXiaoYu_csdn/article/details/73222820

kettle6.1版本,创建数据库资源库连接时,在执行sql语句时出现如下错误:

确定之后继续执行,输入密码点击确定后会出现如下错误:

这是因为执行sql语句时出了问题,如下:

将上图中标记的“N”手动改成1即可,之后再执行可能还会出现类似问题,根据报错内容修改即可。

具体原因我也不知道是什么,欢迎讨论。

展开阅读全文

java 调用kettle资源库报错

04-18

import org.pentaho.di.core.KettleEnvironment;rnimport org.pentaho.di.core.database.DatabaseMeta;rnimport org.pentaho.di.core.exception.KettleException;rnimport org.pentaho.di.repository.RepositoryDirectoryInterface;rnimport org.pentaho.di.repository.kdr.KettleDatabaseRepository;rnimport org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta;rnimport org.pentaho.di.repository.Repository;rnimport org.pentaho.di.trans.Trans;rnimport org.pentaho.di.trans.TransMeta;rnrnrnpublic class test rn rn private static String transName = "test1";rnrn public static void main(String[] args) rnrn try rn //初始化kettle环境rn KettleEnvironment.init();rn //创建资源库对象,此时的对象还是一个空对象rn KettleDatabaseRepository repository = new KettleDatabaseRepository();rn //创建资源库数据库对象,类似我们在spoon里面创建资源库rn DatabaseMeta dataMeta = rn new DatabaseMeta("/","Mysql","Native","192.168.254.49","新闻信息","1521","admin","admin"); rn //资源库元对象,名称参数,id参数,描述等可以随便定义rn KettleDatabaseRepositoryMeta kettleDatabaseMeta = rn new KettleDatabaseRepositoryMeta("enfo_bi", "enfo_bi", "king description",dataMeta);rn //给资源库赋值rn repository.init(kettleDatabaseMeta);rn //连接资源库rn repository.connect("admin","admin");rn //根据变量查找到模型所在的目录对象,此步骤很重要。rn RepositoryDirectoryInterface directory = repository.findDirectory("/enfo_worker/wxj");rn //创建ktr元对象rn TransMeta transformationMeta = ((Repository) repository).loadTransformation(transName, directory, null, true, null ) ;rn //创建ktrrn Trans trans = new Trans(transformationMeta);rn //执行ktrrn trans.execute(null);rn //等待执行完毕rn trans.waitUntilFinished();rn rn if(trans.getErrors()>0)rn rn System.err.println("Transformation run Failure!");rn rn elsern rn System.out.println("Transformation run successfully!");rn rn catch (KettleException e) rn e.printStackTrace(); rn rn rn rnrnrnrnrn下面报错信息 执行到 //连接资源库 报错rnorg.pentaho.di.core.exception.KettleException: rnError connecting to the repository!rnrnError occured while trying to connect to the databasernrnError connecting to database: (using class org.gjt.mm.mysql.Driver)rnCommunications link failurernrnLast packet sent to the server was 0 ms ago.rnrnrnrn at org.pentaho.di.repository.kdr.delegates.KettleDatabaseRepositoryConnectionDelegate.connect(KettleDatabaseRepositoryConnectionDelegate.java:163)rn at org.pentaho.di.repository.kdr.KettleDatabaseRepository.connect(KettleDatabaseRepository.java:174)rn at org.pentaho.di.repository.kdr.KettleDatabaseRepository.connect(KettleDatabaseRepository.java:164)rn at test.main(test.java:32)rnCaused by: org.pentaho.di.core.exception.KettleDatabaseException: rnError occured while trying to connect to the databasernrnError connecting to database: (using class org.gjt.mm.mysql.Driver)rnCommunications link failurernrnLast packet sent to the server was 0 ms ago.rnrnrn at org.pentaho.di.core.database.Database.normalConnect(Database.java:374)rn at org.pentaho.di.core.database.Database.connect(Database.java:323)rn at org.pentaho.di.core.database.Database.connect(Database.java:285)rn at org.pentaho.di.core.database.Database.connect(Database.java:275)rn at org.pentaho.di.repository.kdr.delegates.KettleDatabaseRepositoryConnectionDelegate.connect(KettleDatabaseRepositoryConnectionDelegate.java:140)rn ... 3 morernCaused by: org.pentaho.di.core.exception.KettleDatabaseException: rnError connecting to database: (using class org.gjt.mm.mysql.Driver)rnCommunications link failurernrnLast packet sent to the server was 0 ms ago.rnrn at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:510)rn at org.pentaho.di.core.database.Database.normalConnect(Database.java:358)rn ... 7 morernCaused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failurernrnLast packet sent to the server was 0 ms ago.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)rn at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)rn at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2120)rn at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:723)rn at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)rn at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)rn at java.sql.DriverManager.getConnection(DriverManager.java:582)rn at java.sql.DriverManager.getConnection(DriverManager.java:185)rn at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:490)rn ... 8 morernCaused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failurernrnLast packet sent to the server was 0 ms ago.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)rn at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)rn at com.mysql.jdbc.MysqlIO.(MysqlIO.java:335)rn at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2043)rn ... 20 morernCaused by: java.net.ConnectException: Connection timed out: connectrn at java.net.PlainSocketImpl.socketConnect(Native Method)rn at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)rn at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)rn at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)rn at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)rn at java.net.Socket.connect(Socket.java:519)rn at java.net.Socket.connect(Socket.java:469)rn at java.net.Socket.(Socket.java:366)rn at java.net.Socket.(Socket.java:209)rn at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)rn at com.mysql.jdbc.MysqlIO.(MysqlIO.java:284)rn ... 21 morern 论坛

没有更多推荐了,返回首页