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.
Asked
Active
Viewed 218 times
0
-
1It would help if you were a bit more specific on what exactly you need. – vefthym Apr 30 '14 at 09:07
-
Is this related to Dotcms, or do you simply want to know how to insert data to mysql? – Koen Peters May 01 '14 at 19:59
-
Thanks for the replies. I know how to insert data to MySQL. But I don't know how to do it through dotCMS. Any advice on this? – nliana_ May 14 '14 at 02:19
1 Answers
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