Search This Blog

Saturday, 3 March 2012

procedure to develop java application with type 4 driver i.e.,connector j driver

The Type 4 jdbc driver for mysql provided by vendor company of the mysql database is ------>
connector j jdbc driver.
this driver will not come with mysql installation., so we need to download separately from www.mysql.com

Now procedure to develop java application with type 4 driver i.e.,connector j driver

1)extract mysql-connector-java-3.0.8-stable.zip file into a folder.
2)gather connector j jdbc driver jar file and add that  mysql-connector-java-3.0.8-stable-bin.jar file (this is come from above said zip file) to the CLASSPATH.
3)Now u can develop java applications by using type4 driver..i.e.,
                                         
Driver Name ---> org.gjt.mm.mysql.Driver                                   
URL Sample---->jdbc:mysql://localhost:port number/yourDatabase name

procedure to create mysql datasource name i.e., using type 1 driver.........

procedure to create mysql datasource i.e., using type 1 driver.........

1)keep and install odbc driver for mysql(mysql odbc driver)
2)create DSN for odbc driver for mysql pointing to one or other logical db.

control panel-->performance & maintanance-->Administration tools-->data sources-->userdsn-->add-->mysql odbc driver-->finish.

datasourcename------mysqldsn
host/server name----localhost
database name------- give created logical db name
user----------------root
password------------root
port no-------------3306


------> Test Datasource object--->ok

Friday, 2 March 2012

program to change date format

import java.util.Scanner;
import java.util.*;
import java.text.*;


public class ScanInput {
   public static void main(String[] args)throws Exception {   
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter the input");
        String userInput = scan.next();
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy")
        Date varDate=dateFormat.parse(userInput);
        System.out.print("parsed date is"+varDate);
}
}

Age Calculation based on present date

import java.io.*;
import java.util.*;
public class Age1
{
    public static void main(String[] args)throws IOException
    {
     BufferedReader obj=new BufferedReader(new

InputStreamReader(System.in));
     System.out.println("Enter your dob in dd/mm/yyyy format");
     String date1=obj.readLine();
     int dd1=Integer.parseInt(date1.substring(0,2));
     int mm1=Integer.parseInt(date1.substring(3,5));
     int yy1=Integer.parseInt(date1.substring(6,10));
     System.out.println("Enter present date in dd/mm/yyyy format");
     String date2=obj.readLine();
     int dd2=Integer.parseInt(date2.substring(0,2));
     int mm2=Integer.parseInt(date2.substring(3,5));
     int yy2=Integer.parseInt(date2.substring(6,10));
     int day=0;
     int year=0;
     int mm3=0;
     int k=0;
     if(mm1>mm2)
     {
         year=yy2-yy1-1;
         mm3=12+mm2-mm1;        
     }
     else if(mm1<mm2)
     {
         year=yy2-yy1;
         mm3=mm2-mm1;
     }
     else if(mm1==mm2&&dd2>dd1)
     {
         year=yy2-yy1;
     }
     else if(mm1==mm2&&dd2<dd1)
     {
         year=yy2-yy1-1;
     }
     if(dd2>=dd1)
     {
         day=dd2-dd1;
     }else {
day=dd1-dd2;
}
         System.out.println("your present "+"Age: "+year+" years

"+mm3+" months "+day+" days");
        }
    }

most usefull java links

http://r4r.co.in/java
www.visualbuilder.com/jsp/struts/tutorial
roseindia.com
vaannila.com
java2s.com

Popular Java Links:

Popular Java Links:
1)http://www.javaalmanac.com -
2)http://www.onjava.com -
3)http://java.sun.com - The official Java developer website - new
articles posted weekly.
4)http://www.developer.com/java - Java articles hosted by Gamelan.com
5)http://www.java.net - The Java community website hosted by Sun
Microsystems.
6)http://www.builder.com - Cnet's Builder.com website - All tech
articles, some Java-centric.
7)http://www.ibm.com/developerworks/java - IBM's Developerworks; the
Java section.
8)http://www.javaworld.com - One of the originals. Weekly updates of
Java articles.
9)http://www.devx.com/java - Java articles hosted at DevX.
10)http://www.fawcette.com/javapro - The JavaPro online magazine
website.
11)http://www.sys-con.com/java - The Java Developers Journal online
magazine website.
12)http://www.javadesktop.org - The desktop Java community hosted at
Java.net.
13)http://www.theserverside.com - Often considered the resource for all
discussion server-side Java specific.
14)http://www.jars.com - The Java review service. Covers frameworks and
applications.
15)http://www.jguru.com - A great source for Q&A style interaction in
the community.
16)http://www.javaranch.com
17)http://www.ibiblio.org/javafaq/javafaq.html - The comp.lang.java FAQ
- questions asked, answered, and categorized from the comp.lang.java
newsgroup.
18)http://java.sun.com/docs/books/tutorial/ - The Official Java
tutorial from Sun - very useful for almost any feature set.
19)http://www.javablogs.com - Blog aggregator for the most active
Java-based blogs throughout the internet.
20)http://java.about.com/ - Java news and articles from About.com
21)http://www.javaspecialists.co.za/ The Java Specialist Newsletter.
22)http://www.eclipse.org/ Eclipse main site.
23)http://www.javazoid.com/
24)http://www.esus.com/ Java Tips and Tricks
25)Best open source java projects site
http://www.java-source.net/
26)which class in which jar?
http://www.jarhoo.com/
27)http://www.thauvin.net/linkblog/
28)http://www.clientjava.com/blog/
29)http://javarss.com/
30)http://www.javaskyline.com/ Dedicated to Java.
31)http://semanticdb.blogspot.com
32)For testing your java code /Fragments /JSP
http://zamples.com/JspExplorer/index.jsp
33)http://www.beginner-java-tutorial.com
34)http://www.java-swing-tutorial.com
35)http://www.jdbc-tutorial.com
36)http://www.beginner-java-tutorial.com
37)www.intelligentedu.com (for free it related e-books download)
38)www.precise.com
39)www.coolinterviews.com
40)www.java2s.com
41)www.virtusa.com
42)www.laliluna.de
43)www.roseindia.net
44)www.exampledepot.com
45)www.theserverside.com
46)www.techtarget.com
47)www.java-tips.org
48)www.artima.com
49)www.javafaq.nu
50)www.javaworld.com
51)www.pdfhm.com
52)www.raphidshare.com
53)www.buzzword.com



Developing your first Struts application

Let’s start with developing your first Struts application. Here are the steps involved in creating the Struts application.

        1)Add relevant entries into the web.xml

           a. Add ActionServlet Configuration with initialization parameters
           b. Add ActionServlet Mapping
           c. Add relevant taglib declaration
        2)Start with a blank template for the struts-config.xml. In the  struts-config.xml, add the following

           a. Declare the RequestProcessor
           b. Create a properties file and declare it as Message Resource Bundle
           c. Declare the Message Resource Bundle
           d. Declare the Form-bean
           e. Declare the ActionMapping for the Form-bean
           f. Add the forwards in the ActionMapping
        3)Create the Form-bean class
        4)Create the JSP with Struts tags
        5)Create the Action class
        6)For every <bean:message> tag in the JSP, add key value pairs            to the Message Resource Bundle (properties file) created in             Step 2b
        7)Add Validation in the Form-bean
        8)Define the error messages in the Message Resource Bundle
        9)Create the rest of the JSPs.