zoukankan      html  css  js  c++  java
  • 第八周学习总结

    1.学习了hibernate框架

    2.学习了TensorFlow的验证码识别,通过opencv生成图片

    1.hibernate架构:

    Student.java

    package com.example;
    
    
    public class Student {
        private String ID;
        private String Name;
    
        public Student(){}
        public String getName() {
            return Name;
        }
    
        public void setName(String name) {
            Name = name;
        }
    
        public String getID() {
            return ID;
        }
    
        public void setID(String ID) {
            this.ID = ID;
        }
    }

    Student.hbm.xml

    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-mapping PUBLIC
            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
            "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
        <class name="com.example.Student" table="student">
            <id name="ID" type="java.lang.String">
                <generator class="assigned"></generator>
            </id>
            <property name="Name" type="java.lang.String">
                <column name="Name"></column>
            </property>
    
        </class>
    </hibernate-mapping>

    hibernate.cfg.xml

    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD//EN"
            "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory>
            <property name="connection.url">jdbc:mysql://localhost:3306/lianxi</property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    
            <property name="connection.username">root</property>
            <property name="connection.password">liu123</property>
            <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
            <property name="show_sql">true</property>
            <mapping resource="/com/example/Student.hbm.xml"></mapping>
            <!-- DB schema will be updated if needed -->
            <!-- <property name="hbm2ddl.auto">update</property> -->
        </session-factory>
    </hibernate-configuration>

    Test.java

    package test;
    
    
    import com.example.Student;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    
    public class Test {
        public static void  main(String [] args)
        {
            Configuration configuration=new Configuration();
            configuration.configure("hibernate.cfg.xml");
            SessionFactory sessionFactory = configuration.buildSessionFactory();
            Session session=sessionFactory.openSession();
            Transaction transaction=session.beginTransaction();
            Student student=new Student();
            student.setID("216");
            student.setName("liu");
            session.save(student);
            transaction.commit();
            session.close();
            System.out.println("Successfule saved");
        }
    }
    package test;
    
    
    import com.example.Student;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    
    public class Test {
        public static void  main(String [] args)
        {
            Configuration configuration=new Configuration();
            configuration.configure("hibernate.cfg.xml");
            SessionFactory sessionFactory = configuration.buildSessionFactory();
            Session session=sessionFactory.openSession();
            Transaction transaction=session.beginTransaction();
            Student student=new Student();
            student.setID("216");
            student.setName("liu");
            session.save(student);
            transaction.commit();
            session.close();
            System.out.println("Successfule saved");
        }
    }
  • 相关阅读:
    1024X768大图 (Wallpaper)
    (Mike Lynch)Application of linear weight neural networks to recognition of hand print characters
    瞬间模糊搜索1000万基本句型的语言算法
    单核与双核的竞争 INTEL P4 670对抗820
    FlashFTP工具的自动缓存服务器目录的功能
    LDAP over SSL (LDAPS) Certificate
    Restart the domain controller in Directory Services Restore Mode Remotely
    How do I install Active Directory on my Windows Server 2003 server?
    指针与指针变量(转)
    How to enable LDAP over SSL with a thirdparty certification authority
  • 原文地址:https://www.cnblogs.com/liujinxin123/p/12687517.html
Copyright © 2011-2022 走看看