0

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.

1 Answers1

0

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..." );
shuttsy
  • 1,585
  • 2
  • 19
  • 34