TestConnectionMySQL.java Source code

Java tutorial

Introduction

Here is the source code for TestConnectionMySQL.java

Source

import com.utn.ade.control.HibernateUtil;
import com.utn.ade.modelo.Usuario;
import org.hibernate.Session;
import org.hibernate.Transaction;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Agente 87
 */
public class TestConnectionMySQL {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Session session = HibernateUtil.getSessionFactory().openSession();
        Transaction transaction = session.beginTransaction();
        Long id = (Long) session.load(Usuario.class, "ferrarihe");
        transaction.commit();

    }

}