From 5bb33ab0bca8a15bec90edc0d50bc07c8de33547 Mon Sep 17 00:00:00 2001 From: wang wei Date: Fri, 9 Oct 2015 15:35:50 +0800 Subject: [PATCH] TDI-32579: Job reaches the 65K limit in the tDB2Input component https://jira.talendforge.org/browse/TDI-32579 --- .../java/routines/system/JDBCUtil.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 main/plugins/org.talend.librariesmanager/resources/java/routines/system/JDBCUtil.java diff --git a/main/plugins/org.talend.librariesmanager/resources/java/routines/system/JDBCUtil.java b/main/plugins/org.talend.librariesmanager/resources/java/routines/system/JDBCUtil.java new file mode 100644 index 0000000000..021332aae9 --- /dev/null +++ b/main/plugins/org.talend.librariesmanager/resources/java/routines/system/JDBCUtil.java @@ -0,0 +1,68 @@ +// ============================================================================ +// +// Copyright (C) 2006-2015 Talend Inc. - www.talend.com +// +// This source code is available under agreement available at +// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt +// +// You should have received a copy of the agreement +// along with this program; if not, write to Talend SA +// 9 rue Pages 92150 Suresnes, France +// +// ============================================================================ +package routines.system; + +import java.sql.ResultSet; +import java.util.Date; + +public class JDBCUtil { + + public static String getString(ResultSet rs, int index, boolean trim) throws java.sql.SQLException { + String result = rs.getString(index); + if (trim && result != null) { + return result.trim(); + } + return result; + } + + public static Double getDoubleObject(ResultSet rs, int index) throws java.sql.SQLException { + if (rs.getObject(index) != null) { + return rs.getDouble(index); + } + + return null; + } + + public static Boolean getBooleanObject(ResultSet rs, int index) throws java.sql.SQLException { + if (rs.getObject(index) != null) { + return rs.getBoolean(index); + } + + return null; + } + + public static double getDouble(ResultSet rs, int index) throws java.sql.SQLException { + if (rs.getObject(index) != null) { + return rs.getDouble(index); + } + + throw new RuntimeException("Null value in non-Nullable column"); + } + + public static boolean getBoolean(ResultSet rs, int index) throws java.sql.SQLException { + if (rs.getObject(index) != null) { + return rs.getBoolean(index); + } + + throw new RuntimeException("Null value in non-Nullable column"); + } + + public static Date getDate(ResultSet rs, int index) throws java.sql.SQLException { + if(rs.getTimestamp(index) != null) { + return new Date(rs.getTimestamp(index).getTime()); + } + + return null; + } + +}