no suitable driver at java.sql.DriverManager

出现这样的情况,一般有四种原因: 

一:连接URL格式出现了问题(Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/XX","root","XXXX") 
[qzhao]:我的配置如下: 
<!-- Database connection settings --> 
<property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
<property name="connection.url">jdbc:mysql://10.111.3.244:3306/qzhao_opbook</property> 
<property name="connection.username">qzhao</property> 
<property name="connection.password">qzhao</property> 

<!-- JDBC connection pool (use the built-in) --> 
<property name="connection.pool_size">1</property> 

<!-- SQL dialect --> 
<property name="dialect">org.hibernate.dialect.MySQLDialect</property> 

<!-- Enable Hibernate's automatic session context management --> 
<property name="current_session_context_class">thread</property> 

<!-- Disable the second-level cache  --> 
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 

<!-- Echo all executed SQL to stdout --> 
<property name="show_sql">true</property> 

<!-- Drop and re-create the database schema on startup --> 
<property name="hbm2ddl.auto">update</property> 

<mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml" /> 

而且在我单位电脑能work 

二:驱动字符串出错(com.mysql.jdbc.Driver) 
在sql server 2000 中加载驱动和URL路径的语句是String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=sample";而sql server 2005 中加载驱动和url的语句则为String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=sample";
   
三:Classpath中没有加入合适的mysql_jdbc驱动(驱动要和你的数据库版本一致) 
这个我用的是mysql-connector-java-5.0.4-bin.jar,数据库是5.0 

四:驱动jar包放的位置不对



---------------------------------------------------------------------------------------------------------------------------------
copyright:http://www.cnblogs.com/anee/
原文地址:https://www.cnblogs.com/anee/p/2675903.html