Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: socket cr

來源:互聯網
上載者:User

Q:org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: socket creation error<br />at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:238)<br />at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)<br />at org.springframework.test.AbstractTransactionalSpringContextTests.startNewTransaction(AbstractTransactionalSpringContextTests.java:387)<br />at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:217)<br />at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:101)<br />at junit.framework.TestCase.runBare(TestCase.java:128)<br />at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)<br />at junit.framework.TestResult$1.protect(TestResult.java:106)<br />at junit.framework.TestResult.runProtected(TestResult.java:124)<br />at junit.framework.TestResult.run(TestResult.java:109)<br />at junit.framework.TestCase.run(TestCase.java:120)<br />at junit.framework.TestSuite.runTest(TestSuite.java:230)<br />at junit.framework.TestSuite.run(TestSuite.java:225)<br />at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)<br />at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)<br />at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)<br />at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)<br />at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)<br />at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)<br />Caused by: java.sql.SQLException: socket creation error<br />at org.hsqldb.jdbc.Util.sqlException(Unknown Source)<br />at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)<br />at org.hsqldb.jdbcDriver.getConnection(Unknown Source)<br />at org.hsqldb.jdbcDriver.connect(Unknown Source)<br />at java.sql.DriverManager.getConnection(DriverManager.java:582)<br />at java.sql.DriverManager.getConnection(DriverManager.java:154)<br />at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174)<br />at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165)<br />at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)<br />at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)<br />at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:200)<br />... 18 more

A:多數是因為資料庫沒有開啟的緣故!

若使用的HSQLDB的話,應首先開啟HSQLDB的server,如server.bat
附server.bat內容:
java -classpath ../WebContent/WEB-INF/lib/hsqldb.jar org.hsqldb.Server -database test

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.