无法将数据插入到我的MySQL数据库表中。

huangapple 未分类评论46阅读模式
英文:

cannot insert data to my table in database mysql

问题

i have problem when insert to my database. here my setup for insert to my database.

First, I have method for getExecutionReport

first what i import

    import com.dxtr.hibernate.DAOInsert;
    import com.dxtr.hibernate.newOrderSingleEntity;
        private void getExecutionReport(quickfix.Message message, String tipeMessage) {
        			// TODO Auto-generated method stub
        			 try {
        				 System.out.print("Message "+ message);
        				System.out.print("getExecutionReport "+tipeMessage);
        				newOrderSingleEntity newordersingleObj = new newOrderSingleEntity();
        					newordersingleObj.setSymbol(message.getString(Symbol.FIELD));
        					System.out.print(" symbol "+message.getString(Symbol.FIELD));
        					newordersingleObj.setMsgType(tipeMessage);
        					System.out.print(" tipeMessage "+tipeMessage);
        					newordersingleObj.setBodyLength(216);
        					System.out.print(" Body Length "+216);
        					newordersingleObj.setFixProtocol("FIX.4.2");
        					System.out.print("FixProtocol +FIX.4.2");
        					newordersingleObj.setTransactTime(message.getString(TransactTime.FIELD));
        					System.out.print(" time " +message.getString(TransactTime.FIELD));
        					newordersingleObj.setClOrdID(message.getString(ClOrdID.FIELD));
        					System.out.print(" ClOrdID "+message.getString(ClOrdID.FIELD));
        					newordersingleObj.setOrderID(message.getString(OrderID.FIELD));
        					System.out.print(" OrderID "+message.getString(OrderID.FIELD));
        					newordersingleObj.setExecID(message.getString(ExecID.FIELD));
        					System.out.print(" ExecID "+message.getString(ExecID.FIELD));
        					newordersingleObj.setExecTransType(message.getString(ExecTransType.FIELD));
        					System.out.print(" ExecTransType "+message.getString(ExecTransType.FIELD));
        					newordersingleObj.setOrdType(message.getString(OrdType.FIELD));
        					System.out.print(" OrdType "+message.getString(OrdType.FIELD));
        					newordersingleObj.setExecType(message.getString(ExecType.FIELD));
        					System.out.print(" ExecType "+message.getString(ExecType.FIELD));
        					newordersingleObj.setOrdStatus(message.getString(OrdStatus.FIELD));
        					System.out.print(" OrdStatus "+message.getString(OrdStatus.FIELD));
        					newordersingleObj.setSide(message.getInt(Side.FIELD));
        					System.out.print(" Side "+message.getInt(Side.FIELD));
        					newordersingleObj.setOrderQty(message.getDouble(OrderQty.FIELD));
        					System.out.print(" OrderQty "+message.getDouble(OrderQty.FIELD));
        					newordersingleObj.setLeavesQty(message.getDouble(LeavesQty.FIELD));
        					System.out.print(" LeavesQty "+message.getDouble(LeavesQty.FIELD));
        					newordersingleObj.setCumQty(message.getDouble(CumQty.FIELD));
        					System.out.print(" CumQty "+message.getDouble(CumQty.FIELD));
        					newordersingleObj.setLastShares(message.getInt(LastShares.FIELD));
        					System.out.print(" LastQty "+message.getInt(LastShares.FIELD));
        				
        					System.out.print("sebelum insert ke db");
        				 DAOInsert.newOrderSingleInsert(newordersingleObj);
        				 
        			} catch (FieldNotFound e) {
        				// TODO Auto-generated catch block
        				e.printStackTrace();
        			}
        
        			
        		}

this code ok. but when i want to insert to my database my data cannot insert it.

here my entity

    package com.dxtr.hibernate;
    
    import java.io.Serializable;
    
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Table;
    
    @Entity
    @Table(name="New_Single_Order_Response",schema="dxtr_trades")
    public class newOrderSingleEntity  implements Serializable{
    	 private static final long serialVersionUID = -1234424538928L;
    	  @Id
    	    @Column(name="response_id")
    	    @GeneratedValue(strategy=GenerationType.AUTO)
    	    private Integer id;
    	 
    	    @Column(name="Fix_Protocol")
    	    private String FixProtocol;
    	 
    	    @Column(name="BodyLength")
    	    private Integer BodyLength;
    	 
    	    @Column(name="MsgSeqNum")
    	    private Integer MsgSeqNum;
    	    
    	    @Column(name="MsgType")
    	    private String MsgType;
    	    
    	    @Column(name="SenderCompId")
    	    private String SenderCompId;
    	    
    	    @Column(name="SendingTime")
    	    private String SendingTime;
    	    
    	    @Column(name="TargetCompID")
    	    private String TargetCompID;
    	    
    	    @Column(name="AveragePrice")
    	    private Double AveragePrice;
    	    
    	    @Column(name="ClOrdID")
    	    private String ClOrdID;
    	    
    	    @Column(name="CumQty")
    	    private double CumQty;
    	    
    	    @Column(name="Currency")
    	    private String Currency;
    	    
    	    @Column(name="ExecID")
    	    private String ExecID;
    	    
    	    @Column(name="LastShares")
    	    private double LastShares;
    	    
    	    @Column(name="OrderQty")
    	    private Double OrderQty;
    
    	    @Column(name="OrdStatus")
    	    private String OrdStatus;
    	    
    	    @Column(name="OrdType")
    	    private String OrdType;
    	    
    	    @Column(name="Side")
    	    private Integer Side;
    	    
    	    @Column(name="Symbol")
    	    private String Symbol;
    
    	    @Column(name="TransactTime")
    	    private String TransactTime;
    
    	    @Column(name="ExecType")
    	    private String ExecType;
    	    
    	    @Column(name="LeavesQty")
    	    private double LeavesQty;
    	    
    	    @Column(name="CheckSum")
    	    private Integer CheckSum;
    	    
    	    @Column(name="ExecTransType")
    	    private String ExecTransType;
    
    	    @Column(name="OrderID")
    	    private String OrderID;
    
    
    		public Integer getResponse_ID() {
    			return this.id;
    		}
    
    		public void setResponse_ID(Integer id) {
    			this.id = id;
    		}
    
    		public String getFixProtocol() {
    			return this.FixProtocol;
    		}
    
    		public void setFixProtocol(String FixProtocol) {
    			this.FixProtocol = FixProtocol;
    		}
    
    		public Integer getBodyLength() {
    			return this.BodyLength;
    		}
    
    		public void setBodyLength(Integer BodyLength) {
    			this.BodyLength = BodyLength;
    		}
    
    		public Integer getMsgSeqNum() {
    			return this.MsgSeqNum;
    		}
    
    		public void setMsgSeqNum(Integer MsgSeqNum) {
    			this.MsgSeqNum = MsgSeqNum;
    		}
    
    		
    		public String getMsgType() {
    			return this.MsgType;
    		}
    
    		public void setMsgType(String MsgType) {
    			this.MsgType = MsgType;
    		}
    
    		public String getSenderCompId() {
    			return this.SenderCompId;
    		}
    
    		public void setSenderCompId(String SenderCompId) {
    			this.SenderCompId = SenderCompId;
    		}
    
    		public String getSendingTime() {
    			return this.SendingTime;
    		}
    
    		public void setBodyLength(String SendingTime) {
    			this.SendingTime = SendingTime;
    		}
    
    		public String getTargetCompID() {
    			return this.TargetCompID;
    		

<details>
<summary>英文:</summary>

i have problem when insert to my database. here my setup for insert to my database.

First, I have method for getExecutionReport 

first what i import

    import com.dxtr.hibernate.DAOInsert;
    import com.dxtr.hibernate.newOrderSingleEntity;
        private void getExecutionReport(quickfix.Message message, String tipeMessage) {
        			// TODO Auto-generated method stub
        			 try {
        				 System.out.print(&quot;Message &quot;+ message);
        				System.out.print(&quot;getExecutionReport &quot;+tipeMessage);
        				newOrderSingleEntity newordersingleObj = new newOrderSingleEntity();
        					newordersingleObj.setSymbol(message.getString(Symbol.FIELD));
        					System.out.print(&quot; symbol &quot;+message.getString(Symbol.FIELD));
        					newordersingleObj.setMsgType(tipeMessage);
        					System.out.print(&quot; tipeMessage &quot;+tipeMessage);
        					newordersingleObj.setBodyLength(216);
        					System.out.print(&quot; Body Length &quot;+216);
        					newordersingleObj.setFixProtocol(&quot;FIX.4.2&quot;);
        					System.out.print(&quot;FixProtocol +FIX.4.2&quot;);
        					newordersingleObj.setTransactTime(message.getString(TransactTime.FIELD));
        					System.out.print(&quot; time &quot; +message.getString(TransactTime.FIELD));
        					newordersingleObj.setClOrdID(message.getString(ClOrdID.FIELD));
        					System.out.print(&quot; ClOrdID &quot;+message.getString(ClOrdID.FIELD));
        					newordersingleObj.setOrderID(message.getString(OrderID.FIELD));
        					System.out.print(&quot; OrderID &quot;+message.getString(OrderID.FIELD));
        					newordersingleObj.setExecID(message.getString(ExecID.FIELD));
        					System.out.print(&quot; ExecID &quot;+message.getString(ExecID.FIELD));
        					newordersingleObj.setExecTransType(message.getString(ExecTransType.FIELD));
        					System.out.print(&quot; ExecTransType &quot;+message.getString(ExecTransType.FIELD));
        					newordersingleObj.setOrdType(message.getString(OrdType.FIELD));
        					System.out.print(&quot; OrdType &quot;+message.getString(OrdType.FIELD));
        					newordersingleObj.setExecType(message.getString(ExecType.FIELD));
        					System.out.print(&quot; ExecType &quot;+message.getString(ExecType.FIELD));
        					newordersingleObj.setOrdStatus(message.getString(OrdStatus.FIELD));
        					System.out.print(&quot; OrdStatus &quot;+message.getString(OrdStatus.FIELD));
        					newordersingleObj.setSide(message.getInt(Side.FIELD));
        					System.out.print(&quot; Side &quot;+message.getInt(Side.FIELD));
        					newordersingleObj.setOrderQty(message.getDouble(OrderQty.FIELD));
        					System.out.print(&quot; OrderQty &quot;+message.getDouble(OrderQty.FIELD));
        					newordersingleObj.setLeavesQty(message.getDouble(LeavesQty.FIELD));
        					System.out.print(&quot; LeavesQty &quot;+message.getDouble(LeavesQty.FIELD));
        					newordersingleObj.setCumQty(message.getDouble(CumQty.FIELD));
        					System.out.print(&quot; CumQty &quot;+message.getDouble(CumQty.FIELD));
        					newordersingleObj.setLastShares(message.getInt(LastShares.FIELD));
        					System.out.print(&quot; LastQty &quot;+message.getInt(LastShares.FIELD));
        				
        					System.out.print(&quot;sebelum insert ke db&quot;);
        				 DAOInsert.newOrderSingleInsert(newordersingleObj);
        				 
        			} catch (FieldNotFound e) {
        				// TODO Auto-generated catch block
        				e.printStackTrace();
        			}
        
        			
        		}

this code ok. but when i want to insert to my database my data cannot insert it.

here my entity

    package com.dxtr.hibernate;
    
    import java.io.Serializable;
    
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Table;
    
    @Entity
    @Table(name=&quot;New_Single_Order_Response&quot;,schema=&quot;dxtr_trades&quot;)
    public class newOrderSingleEntity  implements Serializable{
    	 private static final long serialVersionUID = -1234424538928L;
    	  @Id
    	    @Column(name=&quot;response_id&quot;)
    	    @GeneratedValue(strategy=GenerationType.AUTO)
    	    private Integer id;
    	 
    	    @Column(name=&quot;Fix_Protocol&quot;)
    	    private String FixProtocol;
    	 
    	    @Column(name=&quot;BodyLength&quot;)
    	    private Integer BodyLength;
    	 
    	    @Column(name=&quot;MsgSeqNum&quot;)
    	    private Integer MsgSeqNum;
    	    
    	    @Column(name=&quot;MsgType&quot;)
    	    private String MsgType;
    	    
    	    @Column(name=&quot;SenderCompId&quot;)
    	    private String SenderCompId;
    	    
    	    @Column(name=&quot;SendingTime&quot;)
    	    private String SendingTime;
    	    
    	    @Column(name=&quot;TargetCompID&quot;)
    	    private String TargetCompID;
    	    
    	    @Column(name=&quot;AveragePrice&quot;)
    	    private Double AveragePrice;
    	    
    	    @Column(name=&quot;ClOrdID&quot;)
    	    private String ClOrdID;
    	    
    	    @Column(name=&quot;CumQty&quot;)
    	    private double CumQty;
    	    
    	    @Column(name=&quot;Currency&quot;)
    	    private String Currency;
    	    
    	    @Column(name=&quot;ExecID&quot;)
    	    private String ExecID;
    	    
    	    @Column(name=&quot;LastShares&quot;)
    	    private double LastShares;
    	    
    	    @Column(name=&quot;OrderQty&quot;)
    	    private Double OrderQty;
    
    	    @Column(name=&quot;OrdStatus&quot;)
    	    private String OrdStatus;
    	    
    	    @Column(name=&quot;OrdType&quot;)
    	    private String OrdType;
    	    
    	    @Column(name=&quot;Side&quot;)
    	    private Integer Side;
    	    
    	    @Column(name=&quot;Symbol&quot;)
    	    private String Symbol;
    
    	    @Column(name=&quot;TransactTime&quot;)
    	    private String TransactTime;
    
    	    @Column(name=&quot;ExecType&quot;)
    	    private String ExecType;
    	    
    	    @Column(name=&quot;LeavesQty&quot;)
    	    private double LeavesQty;
    	    
    	    @Column(name=&quot;CheckSum&quot;)
    	    private Integer CheckSum;
    	    
    	    @Column(name=&quot;ExecTransType&quot;)
    	    private String ExecTransType;
    
    	    @Column(name=&quot;OrderID&quot;)
    	    private String OrderID;
    
    
    		public Integer getResponse_ID() {
    			return this.id;
    		}
    
    		public void setResponse_ID(Integer id) {
    			this.id = id;
    		}
    
    		public String getFixProtocol() {
    			return this.FixProtocol;
    		}
    
    		public void setFixProtocol(String FixProtocol) {
    			this.FixProtocol = FixProtocol;
    		}
    
    		public Integer getBodyLength() {
    			return this.BodyLength;
    		}
    
    		public void setBodyLength(Integer BodyLength) {
    			this.BodyLength = BodyLength;
    		}
    
    		public Integer getMsgSeqNum() {
    			return this.MsgSeqNum;
    		}
    
    		public void setMsgSeqNum(Integer MsgSeqNum) {
    			this.MsgSeqNum = MsgSeqNum;
    		}
    
    		
    		public String getMsgType() {
    			return this.MsgType;
    		}
    
    		public void setMsgType(String MsgType) {
    			this.MsgType = MsgType;
    		}
    
    		public String getSenderCompId() {
    			return this.SenderCompId;
    		}
    
    		public void setSenderCompId(String SenderCompId) {
    			this.SenderCompId = SenderCompId;
    		}
    
    		public String getSendingTime() {
    			return this.SendingTime;
    		}
    
    		public void setBodyLength(String SendingTime) {
    			this.SendingTime = SendingTime;
    		}
    
    		public String getTargetCompID() {
    			return this.TargetCompID;
    		}
    
    		public void setTargetCompID(String TargetCompID) {
    			this.TargetCompID = TargetCompID;
    		}
    		
    		public Double getAveragePrice() {
    			return this.AveragePrice;
    		}
    
    		public void setAveragePrice(Double AveragePrice) {
    			this.AveragePrice = AveragePrice;
    		}
    
    		public String getClOrdID() {
    			return this.ClOrdID;
    		}
    
    		public void setClOrdID(String ClOrdID) {
    			this.ClOrdID = ClOrdID;
    		}
    		
    		public double getCumQty() {
    			return this.CumQty;
    		}
    
    		public void setCumQty(double CumQty) {
    			this.CumQty = CumQty;
    		}
    
    		public String getCurrency() {
    			return this.Currency;
    		}
    
    		public void setCurrency(String Currency) {
    			this.Currency = Currency;
    		}
    		
    		public String getExecID() {
    			return this.ExecID;
    		}
    
    		public void setExecID(String ExecID) {
    			this.ExecID = ExecID;
    		}
    
    		public double getLastShares() {
    			return this.LastShares;
    		}
    
    		public void setLastShares(double LastShares) {
    			this.LastShares = LastShares;
    		}
    		
    		public Double getOrderQty() {
    			return this.OrderQty;
    		}
    
    		public void setOrderQty(Double OrderQty) {
    			this.OrderQty = OrderQty;
    		}
    
    		public String getExecType() {
    			return this.ExecType;
    		}
    
    		public void setExecType(String ExecType) {
    			this.ExecType = ExecType;
    		}
    
    		public String getOrdStatus() {
    			return this.OrdStatus;
    		}
    
    		public void setOrdStatus(String OrdStatus) {
    			this.OrdStatus = OrdStatus;
    		}
    
    		public String getOrdType() {
    			return this.OrdType;
    		}
    
    		public void setOrdType(String OrdType) {
    			this.OrdType = OrdType;
    		}
    		
    		public Integer getSide() {
    			return this.Side;
    		}
    
    		public void setSide(Integer Side) {
    			this.Side = Side;
    		}
    
    		public String getSymbol() {
    			return this.Symbol;
    		}
    
    		public void setSymbol(String Symbol) {
    			this.Symbol = Symbol;
    		}
    		
    		public String getTransactTime() {
    			return this.TransactTime;
    		}
    
    		public void setTransactTime(String TransactTime) {
    			this.TransactTime = TransactTime;
    		}
    
    		public double getLeavesQty() {
    			return this.LeavesQty;
    		}
    
    		public void setLeavesQty(double LeavesQty) {
    			this.LeavesQty = LeavesQty;
    		}
    		
    		public Integer getCheckSum() {
    			return this.CheckSum;
    		}
    
    		public void setCheckSum(Integer CheckSum) {
    			this.CheckSum = CheckSum;
    		}
    
    		public String getExecTransType() {
    			return this.ExecTransType;
    		}
    
    		public void setExecTransType(String ExecTransType) {
    			this.ExecTransType = ExecTransType;
    		}
    		
    		public String getOrderID() {
    			return this.OrderID;
    		}
    
    		public void setOrderID(String OrderID) {
    			this.OrderID = OrderID;
    		}
    
    		public String toString() {
    	        return &quot;OrderDetail?= Id: &quot; + this.id + &quot;, ClOrdID: &quot; + this.ClOrdID + &quot;, ExecID No.: &quot; + this.ExecID + &quot;, Symbol: &quot; + this.Symbol;
    	    }
    		
    
    
    }

and here my class for insert to database

    package com.dxtr.hibernate;
    
    import java.util.ArrayList;
    import java.util.List;
     
    import org.apache.log4j.Logger;
    import org.hibernate.Query;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
    import org.hibernate.cfg.Configuration;
    import org.hibernate.service.ServiceRegistry;
    
    import quickfix.StringField;
    
    public class DAOInsert {
        private DAOInsert dAOInsert;
        static Session sessionObj;
        static SessionFactory sessionFactoryObj;
     
        public final static Logger logger = Logger.getLogger(DAOInsert.class);
     
        // This Method Is Used To Create The Hibernate&#39;s SessionFactory Object
        public static SessionFactory buildSessionFactory() {
            // Creating Configuration Instance &amp; Passing Hibernate Configuration File
            Configuration configObj = new Configuration();
            configObj.configure(&quot;hibernate.cfg.xml&quot;);
     
            // Since Hibernate Version 4.x, ServiceRegistry Is Being Used
            ServiceRegistry serviceRegistryObj = new StandardServiceRegistryBuilder().applySettings(configObj.getProperties()).build(); 
     
            // Creating Hibernate SessionFactory Instance
            sessionFactoryObj = configObj.buildSessionFactory(serviceRegistryObj);
            return sessionFactoryObj;
        }
    
        public static void newOrderSingleInsert(newOrderSingleEntity newordersingleObj){
              int count = 0;
              try {
                  System.out.print(&quot;sudah di DAOInsert&quot;);
                  // Getting Session Object From SessionFactory
                  sessionObj = buildSessionFactory().openSession();
                  // Getting Transaction Object From Session Object
                  sessionObj.beginTransaction();
                  sessionObj.persist(newordersingleObj);
                  System.out.print(sessionObj.contains(newordersingleObj));
                  // Creating Transaction Entities
                //  newordersingleObj = new NewOrderSingle();             
                  //newordersingleObj.setFixProtocol(&quot;FIX.4.2&quot;);
                  //newordersingleObj.setBodyLength(250);
                      //sessionObj.save(newordersingleObj);
       
                   //Committing The Transactions To The Database
                  sessionObj.getTransaction().commit();
                  //logger.info(&quot;\nSuccessfully Created &#39;&quot; + count + &quot;&#39; Records In The Database!\n&quot;);
              } catch(Exception e) {
                  if(null != sessionObj.getTransaction()) {
                      logger.info(&quot;\n.......Transaction Is Being Rolled Back.......\n&quot;);
                      sessionObj.getTransaction().rollback();
                  }
                  e.printStackTrace();
              } finally {
                  if(sessionObj != null) {
                      sessionObj.close();
                  }
              }
          }
    
    
    
    }

i have also set persistence.xml

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;persistence version=&quot;2.1&quot;
        xmlns=&quot;http://xmlns.jcp.org/xml/ns/persistence&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
        xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd&quot;&gt;
        &lt;persistence-unit name=&quot;FastMatch&quot; transaction-type=&quot;RESOURCE_LOCAL&quot;&gt;
            &lt;class&gt;com.dxtr.hibernate.newOrderSingleEntity&lt;/class&gt;
            &lt;properties&gt;
                &lt;property name=&quot;eclipselink.logging.level&quot; value=&quot;INFO&quot;/&gt;
                 &lt;property name=&quot;eclipselink.logging.level.sql&quot; value=&quot;FINE&quot;/&gt;
                &lt;property name=&quot;eclipselink.logging.parameters&quot; value=&quot;true&quot;/&gt; 
                &lt;property name=&quot;javax.persistence.jdbc.driver&quot; value=&quot;com.mysql.jdbc.Driver&quot; /&gt;
                &lt;property name=&quot;javax.persistence.jdbc.url&quot; value=&quot;jdbc:mysql://trades/tradesnew /&gt;
                &lt;property name=&quot;javax.persistence.jdbc.user&quot; value=&quot;user&quot; /&gt;
                &lt;property name=&quot;javax.persistence.jdbc.password&quot; value=&quot;password&quot; /&gt;
                &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;false&quot; /&gt;
                &lt;property name=&quot;hibernate.format_sql&quot; value=&quot;true&quot; /&gt;
                
                &lt;property name=&quot;hibernate.dialect&quot; value=&quot;org.hibernate.dialect.MySQLDialect&quot; /&gt;
                &lt;property name=&quot;eclipselink.logging.level.connection&quot; value=&quot;FINEST&quot;/&gt;
            &lt;/properties&gt;
        &lt;/persistence-unit&gt;
    &lt;/persistence&gt;

and also i have hibernate.cfg.xml

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    &lt;!DOCTYPE hibernate-configuration PUBLIC
    &quot;-//Hibernate/Hibernate Configuration DTD 3.0//EN&quot;
    &quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;
    &lt;hibernate-configuration&gt;
        &lt;session-factory&gt;
            &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;com.mysql.jdbc.Driver&lt;/property&gt;
            &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc:mysql://url/trades&lt;/property&gt;
            &lt;property name=&quot;hibernate.connection.password&quot;&gt;password&lt;/property&gt;
            &lt;property name=&quot;hibernate.connection.username&quot;&gt;user&lt;/property&gt;
            &lt;property name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
            &lt;property name=&quot;show_sql&quot;&gt;true&lt;/property&gt;
            &lt;property name=&quot;hbm2ddl.auto&quot;&gt;update&lt;/property&gt;
            &lt;mapping class=&quot;com.dxtr.hibernate.newOrderSingleEntity&quot;&gt;&lt;/mapping&gt;
        &lt;/session-factory&gt;
    &lt;/hibernate-configuration&gt;

but when i want to insert to my database this data cannot insert it.. but i don&#39;t know where is the error... i have catch the error using 

    catch(Exception e) {
                  if(null != sessionObj.getTransaction()) {
                      logger.info(&quot;\n.......Transaction Is Being Rolled Back.......\n&quot;);
                      sessionObj.getTransaction().rollback();
                  }
                  e.printStackTrace();
              } finally {
                  if(sessionObj != null) {
                      sessionObj.close();
                  }

but there is no error in my console print... so where is the problem from my code ?
for information i use mysql5.7 version and using aws

best regards,
Fuad


</details>


# 答案1
**得分**: 0

我建议您启用MySQL日志然后按照https://dev.mysql.com/doc/refman/5.7/en/server-logs.html上的说明操作,并确保刷新日志。日志应位于/bar/log/MySQL。

<details>
<summary>英文:</summary>

I would suggest you enable MySQL logs, then follow the instructions at https://dev.mysql.com/doc/refman/5.7/en/server-logs.html and be sure to flush the logs. The logs should be at /bar/log/MySQL



</details>



huangapple
  • 本文由 发表于 2020年4月7日 20:06:55
  • 转载请务必保留本文链接:https://java.coder-hub.com/61079682.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定