最近小弟想使用JAVA开发一个微信公众平台,于是租用了SAE的服务器 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.password">xxxxxxxxxxxxxxxx</property> <property name="hibernate.connection.url">jdbc:mysql://w.rdc.sae.sina.com.cn:3307/app_appname</property> <property name="hibernate.connection.username">xxxxxxxxxxxxxx</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> <mapping resource = "/mapping/NewMapping.hbm.xml"/> </session-factory> </hibernate-configuration> 其中password和username都是从SAE应用管理上面粘下来的,是一堆乱七八糟的东西 下面是newmapping.hbm.xml <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package = "ermengmeng.wxqueue"> <class name="Business" table = "bus"> <id name = "No"></id> <property name = "name"/> </class> </hibernate-mapping> 下面是在doPost中的代码。。。 Configuration conf = new Configuration().configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(conf.getProperties()).build(); SessionFactory sf = conf.buildSessionFactory(serviceRegistry); Session sess = sf.openSession(); Transaction tx = sess.beginTransaction(); Business b = new Business(10,"111"); sess.save(b); tx.commit(); sess.close(); sf.close(); 感觉应该对数据库可以操作了才对。。。是不是我还漏掉了什么。。或者什么地方写的不对。。。求各位大神指教。。 |
|
问题解决了。。。
是我没提供全set/get方法。。。 |
|
100分 |
楼主真的是太聪明啦!膜拜Java大神
|
楼主提供的代码很值得学习!
|
|
用户名是不是SAE_MYSQL_USER这个?
|