简体   繁体   中英

DotCMS : Data insertion to MySQL

I'm a newbie to DotCMS. I've configured ROOT.xml to connect to MySQL. I can retrieve data from MySQL, but I have no idea how to insert/update data to MySQL. Been looking for any examples, couldn't find any. What do I need to do data manipulation on MySQL? Thanks in advance.

If you have a dynamic plugin, then you can create a service that interacts with the database through the dotcms core code for the db connection. Then call the service from whichever controller necessary. Your plugin project will have a dependency on the dotcms core library.

Here's some sample code for your service:

Connection conn = com.dotmarketing.db.DbConnectionFactory.getConnection();
Statement selectStatement = conn.createStatement();
selectStatement.execute( "SELECT * FROM some_table where..." );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM