FIX: Tomcat Catalina Service Fails to Start after Service Restart

Error: From log files: C:Tomcatlogscatalina.2014-01-07.log Jan 7, 2014 7:25:17 AM org.apache.catalina.startup.Catalina start SEVERE: Catalina.start: LifecycleException:  Exception opening database connection:  java.sql.SQLException: ORA-12154: TNS:could not resolve service name     at com.myclasses.security.tomcat.JDBCRealm2.start(Unknown Source)     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1005)     at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)     at org.apache.catalina.core.StandardService.start(StandardService.java:450)     at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)     at org.apache.catalina.startup.Catalina.start(Catalina.java:551)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) Jan 7, 2014 7:25:17 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 4672 ms   Cause: C:Tomcatconfserver.xml has an entry for “com.myclasses.security.tomcat.JDBCRealm2”  that connects tomcat to Oracle server.  If the servername/TNS mentioned for that […]

Read more

Configuring UNIQUE constraint in MYSQL to avoid duplicate entries for a given column/field

MySQL Query: ALTER TABLE `MyLabDB`.`testusers` DROP INDEX `username` , ADD UNIQUE `username` ( `username` ) COMMENT ‘Avoid duplicate entries for username’; phpMyAdmin GUI:   After setting the Unique Index for the field, whenever a duplicate entry is attempted for insertion, mySQL will result in “#1062” error as shown below: #1062 – Duplicate entry ‘user9’ for key ‘username’ < p>

Read more

FIX: MySQL Error: #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 6

MySQL CREATE TRIGGER: CREATE TRIGGER `validate_email_insert` BEFORE INSERT ON `testusers` FOR EACH ROW BEGIN     IF NEW.`email` NOT LIKE ‘%_@%_.__%’ THEN         SIGNAL SQLSTATE VALUE ‘45000’         SET MESSAGE_TEXT = ‘[table:person] – NEW.`email` column is not valid’;     END IF; END;   Error SQL query: CREATE TRIGGER `validate_email_insert` BEFORE INSERT ON `testusers` FOR EACH ROW BEGIN IF NEW.`email` NOT LIKE ‘%_@%_.__%’ THEN SIGNAL SQLSTATE VALUE ‘45000’ SET MESSAGE_TEXT = ‘[table:person] – NEW.`email` column is not valid’; MySQL said: #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the […]

Read more