Test.java Source code

Java tutorial

Introduction

Here is the source code for Test.java

Source

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.Types;

public class Test {
    public static void main(String[] args) throws Exception {
        Connection conn = DriverManager.getConnection("...", "username", "password");
        String query = "{CALL GETDATE(?,?)}";
        CallableStatement callableStatement = (CallableStatement) conn.prepareCall(query);

        callableStatement.setInt(1, 123);
        callableStatement.registerOutParameter(1, Types.DATE);
        callableStatement.executeQuery();

        Date date = callableStatement.getObject(2, Date.class);

    }
}