rapid generator4.0.6怎么配置连接数据库

rapid generator4.0.6怎么配置连接数据库,第1张

1.先启动项目上的h2/bin下的h2.bat或h2w.bat文件,把h2数据库启动起来

2.SSH2框架和h2数据库整合方法

2.1先在数据库下创建 schema目录(相当于一个数据库实例)

create schema fdrkftcode

目的是解决这种异常 org.h2.jdbc.JdbcSQLException: Schema "fdrkftcode" not found...

2.2在schema目录下创建表,如创建系统用户表admin

create table fdrkftcode.admin(

id int primary key,

adminname varchar(50),

username varchar(50),

userpwd varchar(50),

adminrights varchar(50),

createdate datetime,

usedtimes int,

lastlogin datetime,

curstatus int,

remark varchar(200)

)

首先你要明白,save和merge的效果都是没有主键的时候是保存,有主键的时候是更新,但是save执行之后,对象变为持久态,而merge执行过后,对象是脱管状态,也就是说,这时对象的主键是不起作用的。

在你的程序中,每次循环都this.proTechProchead,所以对于save来说第一次过后,对象已经是持久态了,所以之后的 *** 作只是更新,而merge的话,由于第一次之后是托管的,主键不起作用,所以是插入,也正是因为主键不起作用,所以插入的主键就是null

applicationContext.xml文件里,

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:compass="http://www.compass-project.org/schema/spring-core-config"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.compass-project.org/schema/spring-core-config http://www.compass-project.org/schema/spring-compass-core-config-2.1.xsd">

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"

destroy-method="close">

<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mysql" />

<property name="driverClass" value="com.mysql.jdbc.Driver" />

<property name="user" value="root"></property>

<property name="password" value=""></property>

<property name="maxPoolSize" value="40" />

<property name="minPoolSize" value="1" />

<property name="initialPoolSize" value="1" />

<property name="maxIdleTime" value="20" />

</bean>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/sjk/6703287.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-27
下一篇 2023-03-27

发表评论

登录后才能评论

评论列表(0条)

保存