Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Tuesday, December 8, 2015

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver when executing asterix-java AGI server

I implemented an asterisk-java AGI script with MySQL DB integration and tried to execute with following command

java -jar asterisk-java-1.0.0.M3.jar

Server started successfully and called successfully to the service abstract method. How when the call flow met with a scripting line related to DB operations I always got the following run-time error.

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
 
This error can be resolved mentioning the class-path for  

mysql-connector-java-5.1.9.jar

I tried several standard ways to start the AGI server with mentioned class-path for jdbc but failed. Finally I found the way through following answer.
http://stackoverflow.com/questions/8818073/classnotfoundexception-com-mysql-jdbc-driver

I successfully started the AGI server and executed DB related functions by starting the AGI server jar file as follows.

java -classpath asterisk-java-1.0.0.M3.jar:mysql-connector-java-5.1.9.jar:. org.asteriskjava.fastagi.DefaultAgiServer

(asterisk-java-1.0.0.M3.jar & mysql-connector-java-5.1.9.jar are in the same location)

Thursday, July 3, 2014

How to update a table when there is a Foreign Key Constraint

When there is a foriegn key constraint, tables cannot be updated easily in MySQL. A solution for that is disable the foreign key constraint option in the particular MySQL server and do the update. Finally we can enable the foreign key constraint in the particular MySQL server. An important thing to remember is when you disable the foreign key constarint in the server, it affects to each and every table in the MySQL server.  

//Disable the foreign key constraint option 
SET FOREIGN_KEY_CHECKS=0 

//Enable the foreign key constraint option 
SET FOREIGN_KEY_CHECKS=1 

 //Check the state of the foreign key option in the MySQL server 
//0 means Disabled, 1 means Enabled 
SELECT @@FOREIGN_KEY_CHECKS