-
May 8th, 2009, 11:44 AM
#1
Problem accessing a MySQL database
Hi folks.
Sorry for bothering with this stupid question, but i am googling for quite a while now and my books are not of any help at all 
I just simply try to access my local MySQL database. Therefore i bootstrap a datasource to my DAO in the application context:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/Amazonas"/>
<property name="username" value="root"/>
<property name="password" value="torri"/>
</bean>
<bean id="tokenDAO" class="amazonas.tokenDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
So far so good. Now I try to use it in my POJO by:
jlog.log(Level.INFO,"findAll");
List <token> rows = getSimpleJdbcTemplate().query("select * from items", new TokenMapper() );
jlog.log(Level.INFO,"return");
So here comes the gag: In the logfile i just see the first log
08.05.2009 18:34:07 amazonas.tokenDAO findAll
INFO: findAll
Thats it! No error message, no timeout, nothing. Not even the log output in the first line of my row mapper gets displayed.
When i trace into the code, i have the feeling, that the injection of the datasource is not working.
Any ideas????
Thx in advance oad
-
May 9th, 2009, 10:04 AM
#2
Update: I reinstalled my system to Spring 3.0 and Blaze Integration RC1 and .. still the same error. I added some more debug infos and i see, that the SQL Query does not come back
jlog.log(Level.INFO, "Enter");
SimpleJdbcTemplate SJT = getSimpleJdbcTemplate();
jlog.log(Level.INFO, "Get Template");
List rows = SJT.queryForList("SELECT * from Items");
jlog.log(Level.INFO,"return");
return rows;
I also testes the access of my db using a junit test, and with the same configuration, the junit test passes. So somehow, the DataSet ist not injected properly. I have no clue, how to further pin down the error 
Thanks for ideas.
OAD
-
May 9th, 2009, 10:12 AM
#3
I added :
if (this.getDataSource() == null) jlog.log(Level.INFO, "Null");
and ... we have got a little Nullpointer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules