i got error when run my application, the error is:
Specified JDBC Driver com.microsoft.sqlserver.jdbc.SQLServerDriver class not found
my souce: pom.xml
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.20</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
<version>2.3.20</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.1.0.CR2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver.jdbc</groupId>
<artifactId>sqljdbc4</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/lib/sqljdbc4.jar</systemPath>
</dependency>
hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">jdbc:sqlserver://.;database=db</property>
<property name="connection.username">sa</property>
<property name="connection.password">12345</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.SQLServer2005Dialect</property>
<property name="show_sql">false</property>
<property name="hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="employee.hbm.xml"/>
</session-factory>
code that call Hibernate:
public static List<Employee> SelectAll(){
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory = cfg.buildSessionFactory();
Session session = factory.openSession();
//String sql_query= "from Employee where Name = 'Kevin'";
String sql_query= "from Employee";
Query query = session.createQuery(sql_query);
List<Employee> employees = query.list();
session.close();
factory.close();
return employees;
}
Anyone know why? the error happened in SessionFactory factory = cfg.buildSessionFactory();
Directory in:
When i check the library, it Has SQLServerDriver

