整合了三大框架,对数据库操作的时候出错,很多天不知道哪里问题,请高人指教,拜托了,错误信息如下:严重: Servlet.service() for servlet default threw exception
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect.  Invalid URL.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.AbstractBatcher.prepareSelectStatement(AbstractBatcher.java:145)
at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:107)
at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:68)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate
由于帖子长度限制,只贴出了最开始的异常,spring配置文件aplicatonContext.xml信息如下,
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"></property>
<property name="url" value="jdbc:microsoft:sqlserver://localhost:1433/mytest"></property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
<property name="maxActive" value="100"></property>
<property name="maxIdle" value="30"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="sessionFactory"  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property><property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property><property name="mappingResources">
<list>
<value>test/bean/User.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userDao" class="test.dao.impl.UserDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="userService" class="test.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="saveUserAction" class="action.user.SaveUserAction">
<property name="service" ref="userService">
</property>
</bean>
</beans>我不明白为什么url会不可用,求求大家了,帮帮忙吧!

解决方案 »

  1.   

    <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433/mytest"></property>
    改成:<property name="url" value="jdbc:sqlserver://localhost:1433/mytest"></property>try it...
      

  2.   

    SpringConfigs <!-- 引入配置文件 (放在最上面) -->
    <bean id="placeholderConfig"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
    <value>classpath:init.properties</value>
    </property>
    </bean>
    init.properties
    datasource.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
    datasource.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=added
    #datasource.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=website
    datasource.username=sa
    datasource.password=sa
    datasource.minPoolSize=10
    datasource.maxPoolSize=100
    datasource.maxIdleTime=1800
    datasource.acquireIncrement=10
    datasource.initialPoolSize=10
    datasource.idleConnectionTestPeriod=60
    datasource.acquireRetryAttempts=30
    datasource.breakAfterAcquireFailure=true
    datasource.testConnectionOnCheckout=false#hibernate.dialect=org.hibernate.dialect.OracleDialect
    #hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
    hibernate.dialect=org.hibernate.dialect.SQLServerDialect
    hibernate.jdbc.batch_size=0
    hibernate.jdbc.fetch_size=50
    hibernate.show_sql=true
    hibernate.format_sql=true
    hibernate.hbm2ddl.auto=update
    #hibernate.query.factory_class1=org.hibernate.hql.classic.ClassicQueryTranslatorFactory
    #hibernate.query.factory_class1=org.hibernate.hql.ast.ASTQueryTranslatorFactory #hql in ''
    #hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider
    #hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
    #hibernate.cache.provider_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
    #hibernate.cache.use_query_cache=true
      

  3.   

    URL: jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=added