我正在使用Scriptella将数据从一个表复制到 Mysql 上的另一个表(不同的数据库)。对于源代码,我使用了 Mysql 示例数据库 Sakila 中的 table film。
复制数据时,我收到此错误消息。
Exception in thread "main" scriptella.execution.EtlExecutorException: Location: /etl/query[1]/script[1]
JDBC provider exception: Unable to get parameter 4
Error codes: [S1009, 0]
Driver exception: java.sql.SQLException: Cannot convert value '2006' from column 4 to TIMESTAMP.
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:190)
at com.zensar.scrptellaTest.App.main(App.java:21)
Caused by: scriptella.core.ExceptionInterceptor$ExecutionException: /etl/query[1]/script[1] failed: Unable to get parameter 4
at scriptella.core.ExceptionInterceptor.execute(ExceptionInterceptor.java:44)
at scriptella.core.QueryExecutor$QueryCtxDecorator.processRow(QueryExecutor.java:114)
at scriptella.jdbc.StatementWrapper.query(StatementWrapper.java:92)
at scriptella.jdbc.SqlExecutor.statementParsed(SqlExecutor.java:128)
at scriptella.jdbc.SqlParserBase.handleStatement(SqlParserBase.java:129)
at scriptella.jdbc.SqlParserBase.parse(SqlParserBase.java:72)
at scriptella.jdbc.SqlExecutor.execute(SqlExecutor.java:85)
at scriptella.jdbc.JdbcConnection.executeQuery(JdbcConnection.java:222)
at scriptella.core.QueryExecutor.execute(QueryExecutor.java:71)
at scriptella.core.ContentExecutor.execute(ContentExecutor.java:73)
at scriptella.core.ElementInterceptor.executeNext(ElementInterceptor.java:56)
at scriptella.core.StatisticInterceptor.execute(StatisticInterceptor.java:41)
at scriptella.core.ElementInterceptor.executeNext(ElementInterceptor.java:56)
at scriptella.core.ConnectionInterceptor.execute(ConnectionInterceptor.java:36)
at scriptella.core.ElementInterceptor.executeNext(ElementInterceptor.java:56)
at scriptella.core.ExceptionInterceptor.execute(ExceptionInterceptor.java:39)
at scriptella.core.Session.execute(Session.java:103)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:227)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:183)
... 1 more
这是表格中的一行。
'1', 'ACADEMY DINOSAUR', 'A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies', 2006, '1', NULL, '6', '0.99', '86', '20.99', 'PG', 'Deleted Scenes,Behind the Scenes', '2006-02-15 05:03:42'
这里是两个表的 DDL 语句。
sakila.film
CREATE TABLE `film` (
`film_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`description` text,
`release_year` year(4) DEFAULT NULL,
`language_id` tinyint(3) unsigned NOT NULL,
`original_language_id` tinyint(3) unsigned DEFAULT NULL,
`rental_duration` tinyint(3) unsigned NOT NULL DEFAULT '3',
`rental_rate` decimal(4,2) NOT NULL DEFAULT '4.99',
`length` smallint(5) unsigned DEFAULT NULL,
`replacement_cost` decimal(5,2) NOT NULL DEFAULT '19.99',
`rating` enum('G','PG','PG-13','R','NC-17') DEFAULT 'G',
`special_features` set('Trailers','Commentaries','Deleted Scenes','Behind the Scenes') DEFAULT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`film_id`),
KEY `idx_title` (`title`),
KEY `idx_fk_language_id` (`language_id`),
KEY `idx_fk_original_language_id` (`original_language_id`),
CONSTRAINT `fk_film_language` FOREIGN KEY (`language_id`) REFERENCES `language` (`language_id`) ON UPDATE CASCADE,
CONSTRAINT `fk_film_language_original` FOREIGN KEY (`original_language_id`) REFERENCES `language` (`language_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8;
电影
CREATE TABLE `film` (
`film_id` smallint(5) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`description` text,
`release_year` year(4) DEFAULT NULL,
`language_id` tinyint(3) unsigned NOT NULL,
`original_language_id` tinyint(3) unsigned DEFAULT NULL,
`rental_duration` tinyint(3) unsigned NOT NULL DEFAULT '3',
`rental_rate` decimal(4,2) NOT NULL DEFAULT '4.99',
`length` smallint(5) unsigned DEFAULT NULL,
`replacement_cost` decimal(5,2) NOT NULL DEFAULT '19.99',
`rating` enum('G','PG','PG-13','R','NC-17') DEFAULT 'G',
`special_features` set('Trailers','Commentaries','Deleted Scenes','Behind the Scenes') DEFAULT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Scriptella etl.xml
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>Scriptella ETL File Template.</description>
<!-- Connection declarations -->
<connection id="source" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/sakila" user="root" password="12345" />
<connection id="target" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/trg" user="root" password="12345" />
<!-- Uncomment and modify to run a query-based transformation -->
<query connection-id="source">
SELECT * FROM film;
<script connection-id="target">
INSERT INTO film VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13);
</script>
</query>
</etl>
Java 代码
public static void main(String[] args) throws EtlExecutorException {
ProgressIndicatorBase indicatorBase = new ProgressIndicatorBase() {
@Override
protected void show(String label, double progress) {
System.out.println(label + "--> " + progress);
}
};
EtlExecutor.newExecutor(new File("etl.xml")).execute(indicatorBase);
}
请告诉我我在哪里做错了,或者有什么解决方法可以解决它。