[opencms-dev] creating HTML form and submit data to database

Joe Desbonnet jdesbonnet at gmail.com
Tue Apr 4 18:34:46 CEST 2006


You can create your own database pool:

1. Edit opencms.properties and add the following block (and replace
"mydbpool", "mydbname","mydbuser","mydbpassword" as appropriate). This
assumes you are using MySQL database.

db.pool.mydbpool.jdbcDriver=org.gjt.mm.mysql.Driver
db.pool.mydbpool.jdbcUrl=jdbc:mysql://my.db.server.com:3306/mydbname
db.pool.mydbpool.jdbcUrl.params=
db.pool.mydbpool.user=mydbuser
db.pool.mydbpool.password=mydbpassword
db.pool.mydbpool.poolUrl=opencms:mydbpool
db.pool.mydbpool.maxActive=25
db.pool.mydbpool.maxWait=2000
db.pool.mydbpool.maxIdle=10
db.pool.mydbpool.testQuery=
db.pool.mydbpool.whenExhaustedAction=block
db.pool.mydbpool.testOnBorrow=false

2. In the same file (opencms.properties) locate key "db.pools" and add your
pool name (it's a comma separated list)
eg
db.pools=default,mydbpool

3. Restart Opencms/Tomcat. You should now be able to access
connections from your pool.

Eg using JSP code like this:

<%
java.sql.Connection connection =
OpenCms.getSqlManager().getConnection("mydbpool");
String sql = "SELECT name FROM jhl_department WHERE id=" + deptId;
ResultSet rs = connection.createStatement().executeQuery(sql);
... etc ... etc

rs.close();
connection.close();
%>


Joe.

On 4/4/06, Zotter Christian <christian.zotter at oepag.at> wrote:
>
> Hello to all,
>
> I want to include a page with a simple HTML form and submit the data to the
> a self designed table of the database.
> Does OpenCms provide classes for accessing the database? Is there a tutorial
> or documentation existing how to do this?
> I did not find a useful documentation how to do this best till now.
>
> Thanks, Christian (OpenCms beginner)
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>



More information about the opencms-dev mailing list