Announcement Announcement Module
Collapse
No announcement yet.
Problem accessing a MySQL database Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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

    Comment


    • #3
      I added :

      if (this.getDataSource() == null) jlog.log(Level.INFO, "Null");

      and ... we have got a little Nullpointer

      Comment

      Working...
      X