Announcement Announcement Module
Collapse
No announcement yet.
Could not get JDBC Connection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not get JDBC Connection

    Hello,

    I'm a newbie to spring but I somehow got it to work properly, so that data access worked fine for all database operations.

    However, yesterday suddenly an error occured during a database operation.


    Since then, I always get the same error when trying to compile:

    Code:
    Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: User not found: SA
       at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
       at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:577)
       at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:641)
       at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
       at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:698)
       at org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java:112)
       at org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java:122)
       at org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java:137)
       at pmdbproject.pmdb.databasehandling.dao.MovieManager.getAllMovies(MovieManager.java:176)
       at pmdbproject.Controls.MediaTableModel.getDataFromDB(MediaTableModel.java:90)
       at pmdbproject.Controls.MediaTableModel.<init>(MediaTableModel.java:35)
       at pmdbproject.Controls.MediaTable.<init>(MediaTable.java:48)
       at pmdbproject.Controls.MediaLibrary.setupSwing(MediaLibrary.java:113)
       at pmdbproject.Controls.MediaLibrary.<init>(MediaLibrary.java:52)
       at pmdbproject.UI.PMDB.setupSwing(PMDB.java:269)
       at pmdbproject.UI.PMDB.<init>(PMDB.java:75)
       at pmdbproject.UI.PMDB.main(PMDB.java:63)
    Caused by: java.sql.SQLException: User not found: SA
       at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
       at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
       at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
       at org.hsqldb.jdbcDriver.connect(Unknown Source)
       at java.sql.DriverManager.getConnection(DriverManager.java:582)
       at java.sql.DriverManager.getConnection(DriverManager.java:154)
       at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174)
       at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165)
       at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
       at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
       at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
       at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
       ... 16 more
    I'm not an expert, but I think that the relevant part in the XML file for the database access is mainly this one:

    Code:
    <bean id="HsqldbDataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
          <property name="url" value="jdbc:hsqldb:file:/pmdb" />
          <property name="username" value="sa" />
          <property name="password" value="" />
          <property name="connectionProperties">
             <props>
                <prop key="shutdown">true</prop>
             </props>
          </property>
    </bean>

    I haven't changed the username, so I'm totally confused about this error. If you need any more information, please ask me to post it.

    I'm using eclipse and hsqldb.

  • #2
    Maybe you need have a look for the database.script to check the username.

    Or use a database tool to connect the db for try..

    Comment

    Working...
    X