Skip to main content

Posts

Showing posts from 2016

How to use My Eclipse in Java part5

Q.) What is the web applications directory structure? Web project development Q.) How to create web project?  File -> new -> Web project > "Application name" Q.) What is the directory structure of web application?  => According to the sun microsystem there won't be any webroot in the directory structure. But if we are creating the web project in myelipse it will include Webroot in the directory structure and it ill is removed while deploying the application into the server. => All the servlets should be there inside src and all the jsps should be there inside webroot or inside web-inf. => We cannot access the wEB-inf jsp's directly.So in some projects we keep one jsp outside the WEB-INF and all the remaining jsps we keep inside the WEB-INF. => All the generated .class files for the servlets should be there inside classes folder. => Eclipse automatically will move all the .class files to classes folder because the path

chiru 150 movie first look

How to use My Eclipse in Java part4

Q) write a program to understand debugging? most commonly used shortcuts ----------------------------------------- Files / windows control --> save : ctrl+s --> save all : ctrl+shift+s --> maximise / minimise window : ctrl + m --> close a file in the window : ctrl + f4 / ctrl+w --> close all files : ctrl + shift + w --> how to change the file name : right click -> refactor -> rename -->How to change a variable name : select variable + right click on variable + refactor + rename + give new name + press enter. Code Editing --> format code : ctrl+shift+f --> organize imports : ctrl +shift + o --> single line comment OR un comment : ctrl+ / --> multi line comment : ctrl+shift+/ --> multi line un comment : ctrl + shift + \ -->delete line : Ctrl + D --> how to generate setters and getters : -> right click -> source -> generate getters and setters --> short form System.out.println : syso+ ctr

How to use My Eclipse in Java part3

Q.) Add the Javadoc for a jar                                                                                                        --> Download the javadoc of the jar and put it somewhere in your filesystem. --> Open the Java Build Path page of a project (Projects > Properties > Java Build Path). On the Libraries page                      expand the library's node and select the Javadoc location attribute and press Edit             Maintain the location to the API. Important Preference Settings ----------------------------- Window->Preferences -> java -> Editor -> Typing Window -> Preferences -> java -> Editor -> Save Actions => You can export your Preferences settings from one workspace via  File -> Export -> General -> Preferences -> Give file name and location File -> Import -> General -> Preferences -> select exiting preference file  Similar you can import them again into your workspace. Q.) How to i

Struts 2 Part1

Struts 2, Introduction To Struts Framework Let us see the quick and brief introduction to struts 2 framework, struts is an open source framework given by Apache software foundation under one of its projects called Jakarta.  Struts are the framework, used to develop web applications for java with mvc2 architecture. Actually struts 1 was introduced in 2004 and this framework is failed to satisfy the needs of customers in today’s worlds,  finally, Apache joined with OpenSymphony and created struts2.x. struts 2 = webwork2 + struts 1 webwork2 is the framework from OpenSymphony,  java based mvc2. You know what struts 2 is not an extension of struts 1, it's the combination of struts 1 and webwork2 some features taken from struts1 and some from webwork2 and finally released this struts2 framework.   Types of frameworks Frameworks are divided into 2 types, Invasive Non-Invasive Invasive means, it will force the programmers to create their classes by extending or i

How to use My Eclipse in Java part2

Q) What are different kinds of java projects we can develop in myeclipse ? java project => J2se web project => jsp/servlet/struts/spring ejb project  => ejb web service project => web service Enterprise Application Project => ejb + servlets/jsp Q) How to create java project? file -> new -> java project=>enter project name Q) What is the package convention? Inversedomainname.projectname.modulename.technology/usecase package convention  com.companyName.projectName.moduleName.useCase Q.) How to get Content assist? --> The content assistant allows you to get input help in an editor. It can be invoked by CTRL + Space. Q.) How to get Quick Fix ? --> Whenever there is a problem in the code Eclipse will highlight it as an error. Then Select error part and press (Ctrl+1) -->Quick Fix is extremely powerful, it allows you to create new local / instance variables, new methods, classes, put try and catch around your exceptions, assign a statement to a va

How to use My Eclipse in Java part1

Q.) What is the Traditional style of application development? -> Programmers had to edit files, save the files, run the compiler, then the linker, build the application then run it through a debugger. -> Today IDEs bring editor, compiler, linker and debugger into one place along with project management tools to increase programmer productivity. -> Programmers had to edit files, save the files, run the compiler, Q) What is IDE? what are the advantages of using an IDE? -> Integrated Development Environment is a tool where set of programs run from a single user interface. ->easy to use ->Rapid development ->easy to debug...etc. Ex:- Eclipse, MyEclipse , NetBeans, Intelij, RAD, WSAD,  Jdeveloper...etc. Q) What is workspace ?      -> It is a name space where we can store related projects. -> We can choose the workspace during myeclipse startup. Next

JDBC FAQ Part15

33:What is meant by Transaction? How it is possible to maintain Transactions in JDBC applications? Transaction is nothing but an unit of work performed by the applications. Every transaction should have the following properties. Atomicity Consistency Isolation Durability Where atomicity is nothing but perform all the operations or not to perform all the operations in a transaction. That is every transaction must be in either success state or failure state. As part of the jdbc applications when we establish a connection automatically the connection should have a default nature called as “auto commit”. Auto commit in the sense when we send an sql query to the connection then connection will carry that to the DBE and make the DBE to execute provided sql query and store the results on the database per

JDBC FAQ Part14

31:  how to update the database through PreparedStatement object. import java.sql.*; public class PreparedUpdateEx {             public static void main(String[] args)throws Exception             {                         Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection con = DriverMadoeer.getConnection(“jdbc:odbc:doe”,”system”,”jhon”); PreparedStatement pst = con.prepareStatement(“update emp1 set esal = esal+? Where esal<?”); Pst.setInt(1,500); Pst.setFloat(2,10000.0f); Int count = pst.executeUpdate(); System.out.println(“no. of records updated:”+count);                         }             } 32: how to fetch the data from database through PreparedStatement object. import java.sql.*; public class UpdateResEx {             public static void main(String[] args)throws Exception             {                         Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection con = DriverMadoeer.getCon

JDBC FAQ Part13

28:  how to display the data with the respective field names import java.sql.*; public class RSMD1 {             public static void main(String[] args)throws Exception             {                         Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection con = DriverMadoeer.getConnection(“jdbc:odbc:doe”,”system”,”jhon”); Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSEITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs = st.executeQuery(“select * from emp1”);                                     ResultSetMetaData rsmd = rs.getMetaData(); System.out.println(rsmd.getColumnName(1)+”     “+rsmd.getColumnName(2)+”   “+rsmd.getColumnName(3)+”       “+rsmd.getColumnName(4)); System.out.println(“********************************”); while(rs.next()) { System.out.println(rs.getInt(1)+”    “+rs.getString(2)+”    “rs.getFloat(3)+”    “+rs.getString(4));                                     }                         }             }

JDBC FAQ Part12

26:   How to perform  updations on Database throws Updatable ResultSet? By using Updatable ResulSet object we are able to perform some updations on to the database. To perform updations on to the database through Updatable ResultSet object we will use the following steps. Step1:   Get the Updatable ResultSet objectd with the fetched data. Step2:   Move ResultSet cursor to a record where we want to perform updations, for this we will use the following method.                         public void absolute(int recordno.) Step3:   Perform Temporary updations on to the particular record, for this we will use following method.                         public void updateXxx(int fieldno,xxx value) Step4:   Make the temporary updation as a parmenent updation on to the Updatable ResultSet object as well as to the database. For this we will use the following method.                         public void updateRow() The following example demon