Posts

Showing posts with the label Database

To create a Materialized view with FAST REFRESH

Image
Materialized views  is used to replicate data from master(parent) to non-master sites in a replication environment. at non-master site it is replica of master site. so it is also known as ' snapshots' of master. Need of Materialized views :-                             Suppose I have two application, 1. for User Administration 2. actual user console. where based on user role user can perform different task. like Admin user can do administrative work, support user can monitor session, or see logs, and normal user can do all other things.                            For Both this application I have different schema, from User console while logging into application, i have to check user role given in User Administration console. So I need data from other application and which need to be synchronized. we can do this by DB jobs but t he...

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.

When I was trying to delete records from orderednotcompltedcarts tables when my customers order is succesfully placed. But when i tried to delete records form table by using below query delete from orderednotcompletecarts where custphone='1234567890'; it reports the above mentioned error :  Solution : -   It’s because I tried to update a table without a WHERE that uses a KEY column. The quick fix is to add SET SQL_SAFE_UPDATES=0; before delete query : SET SQL_SAFE_UPDATE=0 ; Or close the safe update mode  Go to  Edit -> Preferences -> SQL Queries and  disable Forbid UPDATE and DELETE statements with no key in where clause or no LIMIT clause.But you require to reconnect to make it available. Hope So You solve your problem with same solution. If not, then please update your problem in comments.

Set current date as default for date Type in mysql

I have  to add new columns in table 'order' namely shippedDate and last_updated  which consist of datetime data type. i would like to do the following. a) Set shippedDate defaults value to MySQL NOW() or CURRENT_DATE    b) Set last_updated default value to  CURRENT_TIMESTAMP   Instead of null which it uses by default. as the table already exist and it already some existing records i would like to do Modify table, i tried using two different code but none is working. ALTER TABLE orders  ADD COLUMN  shippedDate   Date NULL default  CURRENT_DATE   AFTER 'previoueColumn' , ADD COLUMN ` last_updated  ` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP  AFTER ` shippedDate  ` ; It gives me Error :Error 1067 : Invalid default value for  shippedDate. is it possible for me to set the default datetime value to NOW() in MySQL? thank you...

SOLVED :- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Exception :-  Please provide me a solution to following error when i try to run Java file which has connections to MYSQL database.  [javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver] with root cause java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.apache.jsp.login_jsp._jspService(login_jsp.java:62) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(J...