Hello Friends...
I have one urgent query...
Please help me solving it.

I am trying to use PreparedStatementCreator interface.
By making an anonymous inner class,i have implemented it's createPreparedStatement(Connection) method.
When this method is implemented, it will automatically called every time.
But, I want to know which is that connection object being passed to this method?
I am getting a exaception and the error message that is coming is Connection Refused.
Here's the code..

GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();

        insertResult = adapterJdbcTemplate.update(
                new PreparedStatementCreator() {

                    @Override
                    public PreparedStatement createPreparedStatement(
                            Connection connection) throws SQLException {

                        PreparedStatement preparedStatement = connection
                                .prepareStatement(query);
                        preparedStatement.setTimestamp(1,
                                pollingLog.getStartDate());
                        preparedStatement.setInt(2, pollingLog.getStatus());

                        return preparedStatement;
                    }
                }, generatedKeyHolder);

Please have a look and suggest me how to solve this issue...
Thanks & Regards,
Sumit Desai

Recommended Answers

All 2 Replies

The "connection object coming to it" is the one provided to it by whatever calls it. What calls it? Where did that get its connection? I assume you do know what your program does, right?

Thnx a lot...Of course I know what my code does..
But the problem was very small.My IP address wasn't having the privilages to access the database server..That's it..Had to add those manually and it was done....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.