Posts

Showing posts from 2013

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 hese operations are expensive in terms of time and processing power. As DB jobs mostly given on time scheduling. So if in given time nothing is

dda line drawing algorithm in java

Read about DDA (Digital differential analyzer) algorithm . You can find line drawing using bresenham's line algorithm here . Java Code for DDA line drawing algorithm. :- package applet; import java.applet.Applet; import java.awt.Button; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; public class dda extends Applet implements MouseListener, MouseMotionListener, ActionListener {     int x1 = -1, y1 = -1, x2 = -1, y2 = -1,     //coordinates of start and end points             pixelsize = 12,                     //size of pixel in raster             xa = 0, xfin = 0, yfin = 0,         //increment and end point coordinates used in animation             dif = 0;                            //increment on main axis     Button refresh = new Button(&quo

Bresenham line drawing algorithm in java

   My friend Sandip is doing M.Tech from one of the reputed college. His lecturer asked him to do Java code for line drawing using Bresenham s , DDA algorithm. So I am posting this blog for  Bresenham line drawing algorithm in java and you can find line drawing using DDA algorithm  here . Read more about Bresenham's line algorithm  . Java code :-  package applet; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; public class bresenhamLine extends java.applet.Applet implements MouseListener, MouseMotionListener { private static final long serialVersionUID = 1L; int width, height; int x1 = 0, y1 = 0, x2 = 0, y2 = 0, pixelsize = 2; public void init() {      width = getSize().width;      height = getSize().height;      this.addMouseListener(this);       this.addMouseMotionListener(this);     } // draw a

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...

javax.mail.AuthenticationFailedException: 535 No SMTP server defined. Use real server address instead of 127.0.0.1 in your account.

I am trying to send mail using below program :-  public class mail { public static void main(String[] args) { final String username = "****@gmail.com"; final String password = "****"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props,  new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); }  }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("piyush.mundada89@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("piyush.mundada89@gmail.com&

Parsing error processing resource path /WEB-INF/struts-config.xml

I am using struts  to develop an apps. I get the following error while trying to load the application. issue 1 :  org.xml.sax.SAXParseException; systemId: jndi:/project/WEB-INF/struts-config.xml;  The end-tag for element type "action" must end with a '>' delimiter. issue 2 :   javax.servlet.UnavailableException: Parsing error processing resource path /WEB-INF/struts-config.xml SOLUTION :-   One thing i know that  parsing error means that Struts couldn't parse one or more of config xml files. From the message, it sounds like the problem is in the  struts-config.xml; After doing long R&D, I found that i have done small mistake while configuring  struts-config.xml; My struts-config.xml :-  <action-mappings>         <action             path="/Welcome" type="*****.Action" scope="request" validate="true">             <forward name="success" path="/**.do?reqCode=**

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(JspServlet