Maven setting up the Internal Repository

Add internal repository from project

${basedir} is variable of eclipse

Local File In Project
Local Repo

Add dependency

  • When using command mvn eclipse:eclipse , maven will copy file from folder repo to folder .m2 (C:\Users\EURO\.m2\repository\com\amazon\RedshiftJDBC41\1.1.9.1009)
  • On EC2 server you must deploy your library to folder /usr/lib/jvm/jre/lib/ext/RedshiftJDBC41-1.1.9.1009.jar.

Different between RDS and RS

Insert data

Inserting big data on Redshift is easily and quickly.

Inserting single row on redshift using JDBC, it will be take very long time.

Divide two integer number

example 1/3

  • Result of RDS : 0.3333
  • Result of Redshift : 0

Double quote

On RS double quote mean avoid duplicate syntax of system

  • Example 1 : When set alias column name
    • Query : SELECT HOGE AS CVR(CV1) FROM HOGE

RDS : SELECT HOGE AS CVR(CV1) FROM HOGE

RS: SELECT HOGE AS “CVR(CV1)” FROM HOGE

  • Example 2 : In where condition
    • Query : SELECT A FROM TABLE WHERE A = “検索”

RDS : OK

RS : Error , we must change double quote to single quote

JDBC and the “zero” date

A few weeks ago, I was in the process of writing a little script in Java to extract data from a MySQL database. Because this is what we can call a micro project, I decided to simply use JDBC to talk to the database.

But when I tried to run my script, I got the following exception:

After looking at the database, it seems that this exception has been thrown because the fields of type

contain the value ‘0000-00-00 00:00:00’. Don’t ask me why I have this kind of value in the database! Obviously, we would prefer to have a

value instead of a “zero” date.

There are two solutions to fix this problem:

  1. Replace all the “zero” dates by using the following SQL query:

2.   Add the parameter

to the connection url which will automatically convert the “zero” date to

. Please find below an example of connection url with this parameter:

Personally, I choose the second solution as I didn’t want to change the original data of the database.

Copy From : http://www.logikdev.com/tag/zerodatetimebehavior/