Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bidirectional Converters and Quirks #70

Merged
merged 5 commits into from
Apr 7, 2014
Merged

Bidirectional Converters and Quirks #70

merged 5 commits into from
Apr 7, 2014

Conversation

aldenquimby
Copy link
Contributor

Before merging, I want to test on a DB2 database because the Query#addParameter(String, Date) no longer exists. @aaberg do you have a DB2 db available to you?

Note: at some point we may want to move the quirks implementations to respective extension packages

@aldenquimby aldenquimby self-assigned this Apr 6, 2014
@aaberg
Copy link
Owner

aaberg commented Apr 6, 2014

@aldenquimby I think I will get an opportunity to test it on a DB2 database tomorrow or Tuesday.

@dimzon
Copy link
Contributor

dimzon commented Apr 6, 2014

I have DB2 @ office

@aaberg
Copy link
Owner

aaberg commented Apr 6, 2014

@dimzon It would be great if you have an opportunity to test! The problem is that executing an insert/update on a DateTime/Timestamp column with a java.util.Date value, will not save time information (only date) on some databases (MS SQL, MySQL and PostgreSQL). If we convert it to a java.sql.Timestamp value, it crashes on DB2 when using as a parameter for a Date column.

I will also try to get an opportunity to test it on DB2. But I will check here first, to see if you have already testet :)

@dimzon
Copy link
Contributor

dimzon commented Apr 6, 2014

@aaberg
DB2 is very "strict". During my ORM development pratice I have a most of problems with it (MySQL was a second because lack of features)...

@dimzon
Copy link
Contributor

dimzon commented Apr 7, 2014

jccVersion==IBM DB2 JDBC Universal Driver Architecture 3.53.71
driverType=4
CREATE TABLE DT_TEST  ( 
    F1  DATE,
    F2  TIME,
    F3  TIMESTAMP 
    )
        try(Connection cn = ds.getConnection()){
            try(PreparedStatement ps = cn.prepareStatement("insert into dt_test(f1,f2,f3) values(?,?,?)")){
                Object date = new java.sql.Timestamp(System.currentTimeMillis());
                ps.setObject(1, date);
                ps.setObject(2, date);
                ps.setObject(3, date);
                ps.executeUpdate();
            }
        }

works fine for all 3 fields

@aaberg
Copy link
Owner

aaberg commented Apr 7, 2014

@dimzon what happens if you use a java.sql.Timestamp instead of date?

ps.setObject(1, timestamp);

On Mon, Apr 7, 2014 at 11:52 AM, dimzon notifications@github.com wrote:

jccVersion==IBM DB2 JDBC Universal Driver Architecture 3.53.71
driverType=4

CREATE TABLE DT_TEST (
F1 DATE,
F2 TIME,
F3 TIMESTAMP
)IN

    try(Connection cn = ds.getConnection()){
        try(PreparedStatement ps = cn.prepareStatement("insert into dt_test(f1,f2,f3) values(?,?,?)")){
            Object date = new java.sql.Timestamp(System.currentTimeMillis());
            ps.setObject(1, date);
            ps.setObject(2, date);
            ps.setObject(3, date);
            ps.executeUpdate();
        }
    }

works fine for all 3 fields

Reply to this email directly or view it on GitHubhttps://github.com//pull/70#issuecomment-39712847
.

@dimzon
Copy link
Contributor

dimzon commented Apr 7, 2014

@aaberg re-read my code above. I'm using java.sql.Timestamp and it works fine

@aaberg
Copy link
Owner

aaberg commented Apr 7, 2014

Ahh, your right. I didn't see that. Which jdbc driver and version do you use?

@aaberg
Copy link
Owner

aaberg commented Apr 7, 2014

Forget it! You wrote that too!!! I need to learn to read!

@dimzon
Copy link
Contributor

dimzon commented Apr 7, 2014

also in upper post

2014-04-07 15:04 GMT+04:00 Lars Aaberg notifications@github.com:

Ahh, your right. I didn't see that. Which jdbc driver and version do you
use?

Reply to this email directly or view it on GitHubhttps://github.com//pull/70#issuecomment-39717759
.

@aaberg aaberg added this to the 1.4.1 milestone Apr 7, 2014
Conflicts:
	core/src/main/java/org/sql2o/PojoResultSetIterator.java
aaberg added a commit that referenced this pull request Apr 7, 2014
Bidirectional Converters and Quirks
@aaberg aaberg merged commit c17de2e into master Apr 7, 2014
@aaberg aaberg deleted the converters_v2 branch April 7, 2014 20:28
@aaberg aaberg modified the milestones: 1.5.0, 1.4.1 Apr 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants