Saturday 3 March 2018

19.0 Hibernate Project setup

To build Hibernate applications , you need the following

  1. Java Integrated Development Environment
  2. Database Server
  3. Hibernate JAR files and JDBC driver

Install MySQL (Installation Steps)

import all the hibernate related jar files in your project build path (Hibernate jars)
mysql connector driver (Download)

Write a small jdbc code to test the connectivity 

----------------------------------------------------------------------------------------
TestJdbc.java
----------------------------------------------------------------------------------------

package com.bikesh.test;

import java.sql.DriverManager;

import org.hibernate.dialect.MySQL55Dialect;

import com.mysql.jdbc.Connection;

public class TestJdbc {

public static void main(String[] args) {
String jdbcUrl="jdbc:mysql://localhost:3306/bikesh?useSSL=false";
String user="root";
String pass="root";
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connecting to jdbc:"+jdbcUrl);
java.sql.Connection myConn=DriverManager.getConnection(jdbcUrl,user,pass);
System.out.println("Connection Successful");
}
catch(Exception e)
{
e.printStackTrace();
}

}

}



No comments:

Post a Comment