Herong. Yang. com, All Rights Reserved. My. Sql. Load. Driver. String args. Connection con null. System. out. printlnBefore loading SQLServer. Driver. list. Drivers. Load the My. SQL JDBC driver. Class. Namecom. mysql. Driver. System. After loading SQLServer. Driver. list. Drivers. Exception e. System. Exception e. Message. Drivers. Enumeration driver. List Driver. Manager. Drivers. while driver. List. has. More. Elements. Driver driver. Class Driver driver. List. next. Element. System. out. println driver. Class. get. Class. Name. The compilation and execution tests with JDK 1. C herong Progra1javajdk. My. Sql. Load. Driver. C herong Progra1javajdk. My. Sql. Load. Driver. Before loading SQLServer. Driver. com. mysql. Driver. com. mysql. Fabric. My. SQLDriver. After loading SQLServer. Driver. com. mysql. Driver. com. mysql. Fabric. My. SQLDriver. JDBC driver classes were loaded automatically before calling the Class. Name. to load them explicitly. I am sure that the com. Driver class is the JDBC driver class for. My. SQL server. I am not sure what the com. Fabric. My. SQLDriver driver class is for. Last update 2. 01. Table of Contents About This Book JDBC Java Database Connectivity Introduction JDK Java SE Installation Installing and Running Java DB Derby Derby Java DB JDBC Driver Derby Java DB JDBC Data. Source Objects Java DB Derby DML Statements Java DB Derby Result. Set Objects of Queries Java DB Derby Prepared. Statement My. SQL Installation on WindowsMy. SQL JDBC Driver My. SQL ConnectorJ My. SQL ConnectorJ Download and InstallationLoading JDBC Driver for My. SQL Server JDBC Driver Connection URL Creating Connections with Data. Source Class Getting Driver and Server Information Creating Tables with AUTOINCREMENT Columns INSERT INTO Statements My. SQL Prepared. Statement My. SQL Reference Implementation of Jdbc. Row. Set My. SQL JBDC Callable. Statement My. SQL CLOB Character Large Object TEXT My. SQL BLOB Binary Large Object BLOB Oracle Express Edition Installation on Windows Oracle JDBC Drivers Oracle Reference Implementation of Jdbc. Row. Set Oracle Prepared. Statement Oracle JBDC Callable. Statement Oracle CLOB Character Large Object TEXT Oracle BLOB Binary Large Object BLOB Microsoft SQL Server 2. Express Edition Microsoft JDBC Driver for SQL Server sqljdbc. Microsoft JDBC Driver Query Statements and Result Sets Microsoft JDBC Driver Database. Meta. Data Object Microsoft JDBC Driver DDL Statements Microsoft JDBC Driver DML Statements SQL Server Prepared. Statement SQL Server CLOB Character Large Object TEXT SQL Server BLOB Binary Large Object BLOB JDBC ODBC Bridge Driver sun. Jdbc. Odbc. Driver JDBC ODBC Bridge Driver Flat Text Files JDBC ODBC Bridge Driver MS Access JDBC ODBC Bridge Driver MS SQL Server Summary of JDBC Drivers and Database Servers Additional Tutorial Notes to Be Added Outdated Tutorials References PDF Printing Version. Spring MVC Hibernate My. SQL Integration CRUD Example Tutorial. We learned how to integrate Spring and Hibernate in our last tutorial. Today we will move forward and integrate Spring MVC and Hibernate frameworks in a web application CRUD example. Our final project structure looks like below image, we will look into each of the components one by one. Note that I am using Spring 4. Release and Hibernate 4. Final versions for our example, same program is also compatible for Spring 4 and Hibernate 3, however you need to make small changes in spring bean configuration file discussed in the last tutorial. Maven Dependencies. Lets look at all the maven dependencies are required for hibernate and spring mvc framework integration. UTF 8. lt project xmlnshttp maven. POM4. 0. 0 xmlns xsihttp www. XMLSchema instance. Locationhttp maven. POM4. 0. 0 http maven. Version 4. 0. Version. Id com. journaldev. Id. lt artifact. Id Spring. MVCHibernatelt artifact. Id. lt name Spring. MVCHibernatelt name. BUILD SNAPSHOTlt version. RELEASElt org. Finallt hibernate. Spring. lt dependency. Id org. springframeworklt group. Id. lt artifact. Id spring contextlt artifact. Id. lt version org. Exclude Commons Logging in favor of SLF4j. Id commons logginglt group. Id. lt artifact. Id commons logginglt artifact. Id. lt exclusion. Id org. springframeworklt group. Id. lt artifact. Id spring webmvclt artifact. Id. lt version org. Id org. springframeworklt group. Id. lt artifact. Id spring txlt artifact. Id. lt version org. Hibernate. Id org. Id. lt artifact. Id hibernate corelt artifact. Id. lt version hibernate. Id org. hibernatelt group. Id. lt artifact. Id hibernate entitymanagerlt artifact. Id. lt version hibernate. Apache Commons DBCP. Id commons dbcplt group. Id. lt artifact. Id commons dbcplt artifact. Id. lt version 1. Spring ORM. Id org. Id. lt artifact. Id spring ormlt artifact. Id. lt version org. Aspect. J. Id org. Id. lt artifact. Id aspectjrtlt artifact. Id. lt version org. Logging. lt dependency. Id org. slf. 4jlt group. Id. lt artifact. Id slf. Id. lt version org. Id org. slf. 4jlt group. Id. lt artifact. Id jcl over slf. Id. lt version org. Id org. slf. 4jlt group. Id. lt artifact. Id slf. Id. lt version org. Id log. 4jlt group. Id. lt artifact. Id log. Id. lt version 1. Id javax. maillt group. World Of Ideas 9Th Edition Ebook. Id. lt artifact. Id maillt artifact. Id. lt exclusion. Id javax. jmslt group. Id. lt artifact. Id jmslt artifact. Id. lt exclusion. Id com. sun. jdmklt group. Id. lt artifact. Id jmxtoolslt artifact. Id. lt exclusion. Id com. sun. jmxlt group. Id. lt artifact. Id jmxrilt artifact. Id. lt exclusion. Inject. lt dependency. Id javax. injectlt group. Id. lt artifact. Id javax. Id. lt version 1lt version. Servlet. lt dependency. Id javax. servletlt group. Id. lt artifact. Id servlet apilt artifact. Id. lt version 2. Id javax. servlet. Id. lt artifact. Id jsp apilt artifact. Id. lt version 2. Id javax. servletlt group. Id. lt artifact. Id jstllt artifact. Id. lt version 1. Test. lt dependency. Id junitlt group. Id. lt artifact. Id junitlt artifact. Id. lt version 4. Id maven eclipse pluginlt artifact. Id. lt version 2. Projectnatures. Projectnatures. Buildcommands. Buildcommands. Sources truelt download. Sources. lt download. Javadocs truelt download. Javadocs. lt configuration. Id org. apache. Id. Id maven compiler pluginlt artifact. Id. lt version 2. Argument Xlint alllt compiler. Argument. lt show. Warnings truelt show. Warnings. lt show. Deprecation truelt show. Deprecation. lt configuration. Id org. codehaus. Id. lt artifact. Id exec maven pluginlt artifact. Id. lt version 1. Class org. test. Mainlt main. Class. Name project. Idlt final. Name. Some of the dependencies above are included by STS Spring Tool Suite when I create Spring MVC project. Important dependencies above are spring context, spring webmvc, spring tx, hibernate core, hibernate entitymanager and spring orm. I am using Apache Commons DBCP for connection pooling, but in real life situations, most probably you have connection pooling done by the container and all we need is to provide the JNDI reference details to use. NOTE I noticed that some of the readers are getting database connection issues. Notice that in my pom. That works for me because I have My. SQL driver in tomcat lib directory and some Data. Source connections configured with it. For any database connection related issues, either put the database driver in container lib or include that in pom. Deployment Descriptor. We need to plugin spring framework in our web application, that is done by configuring Spring framework Dispatcher. Servlet as front controller. Our web. xml file looks like below. UTF 8. lt web app version2. XMLSchema instance. Locationhttp java. The definition of the Root Spring Container shared by all Servlets and Filters. Config. Locationlt param name. WEB INFspringroot context. Creates the Spring Container shared by all Servlets and Filters. Context. Loader. Listenerlt listener class. Processes application requests. Servletlt servlet name. Dispatcher. Servletlt servlet class. Config. Locationlt param name. WEB INFspringapp. Servletservlet context. Servletlt servlet name. Most of the part is boiler plate code, most important part is the spring context file location where we will configure our spring beans and services. If you want, you can change them according to your project requirements. Hibernate Entity Bean. We are using JPA annotations in our entity bean class, however we can also have a simple java bean and mapping details in the xml file. In that case, we need to provide mapping file details while configuring Hibernate Session. Factory in spring bean configurations. Column. import javax. Entity. import javax. Generated. Value. Generation. Type. Id. import javax. Table. Entity bean with JPA annotations. Hibernate provides JPA implementation. TablenamePERSON. Person. Columnnameid. Generated. ValuestrategyGeneration. Type. IDENTITY. private int id. String name. private String country. Id. public void set. Idint id. this. String get. Name. NameString name. String get. Country. CountryString country. String to. String. Our entity bean maps to PERSON table in My. SQL database, notice that I have not annotated name and country fields with Column annotation because they are of same name. Below SQL script shows the table details. CREATE TABLE Person. NOT NULL AUTOINCREMENT. NOT NULL DEFAULT. DEFAULT NULL. PRIMARY KEY id. ENGINEInno. DB AUTOINCREMENT1 DEFAULT CHARSETutf. Hibernate DAO Implementation. We will create Person. DAO interface to declare the methods that we will use in our project. Next, we will provide hibernate specific implementation for it. List. import com. Person. public interface Person. DAO. public void add. PersonPerson p. PersonPerson p. Listlt Person list. Persons. public Person get. Person. By. Idint id.