Posts

Showing posts from 2009

short cut for System.out.println configuration on myeclipse or eclipse

To customize the System.out.println() in to three letters word like "sop" as like sysout... go to window--> prference--> java-- > editor-- > template--> add--> give yourshortcut code and describe that value and code

Hibernate

1. First create project in eclipse(either java project/webproject) 2. configure the required jar for sql or mysql or any data base 2. right click on project and Add hibernate capabilities 3. then configure the hibenate configureation file Generated by MyEclipse Hibernate Tools. --> org.hibernate.dialect.MySQLDialect jdbc:mysql://localhost:3306/frameworkdb root 12345678 com.mysql.jdbc.Driver true update 4. create the POJO code that will map the table column names eg. /** * */ package com.hib.to; /** * @author kumar.ganapathy * */ public class Authenticate { private long uid; private String userName; private String passWord; /** * @return the uid */ public long getUid() { return uid; } /** * @param uid the uid to set */ public void setUid(long uid) { this.uid = uid; } /** * @return the userName */ publ...

struts 2 first configuration

roject structure : lib folders should have the following commons-logging-1.0.4.jar commons-logging-api-1.1.jar freemaker-2.3.13.jar ognl-2.6.11.jar struts2-core-2.1.6.jar xwork-2.1.2.jar commons-fileload-1.2.1.jar struts-core-1.3.10.jar then remaining as per the developer needs. first write the Action class HelloAction.java eg package com.struts.sample.action; import com.opensymphony.xwork2.ActionSupport; public class HelloAction extends ActionSupport{ String greetings = "test"; public String execute() throws Exception { if(greetings.equals("kumar")){ setGreetings("Hello World tested"); return SUCCESS; }else { setGreetings("Praveen"); return "Fail"; } } /** * @return the greetings */ public String getGreetings() { return greetings; } /** * @param greetings the greetings to set */ public void setGreetings(String greetings) { this.greetings = greetings; } } 2. create jsp files, 2.1 index.jsp Struts 2 Example...

A List of JDBC Drivers

A List of JDBC Drivers If you need to access a database with Java, you need a driver. This is a list of the drivers available, what database they can access, who makes it, and how to contact them. IBM DB2 jdbc:db2:// : / COM.ibm.db2.jdbc.app.DB2Driver JDBC-ODBC Bridge jdbc:odbc: sun.jdbc.odbc.JdbcOdbcDriver Microsoft SQL Server jdbc:weblogic:mssqlserver4: @ : weblogic.jdbc.mssqlserver4.Driver Oracle Thin jdbc:oracle:thin:@ : : oracle.jdbc.driver.OracleDriver PointBase Embedded Server jdbc:pointbase://embedded[: ]/ com.pointbase.jdbc.jdbcUniversalDriver Cloudscape jdbc:cloudscape: COM.cloudscape.core.JDBCDriver Cloudscape RMI jdbc:rmi:// : /jdbc:cloudscape: RmiJdbc.RJDriver Firebird (JCA/JDBC Driver) jdbc:firebirdsql:[// [: ]/] org.firebirdsql.jdbc.FBDriver IDS Server jdbc:ids:// : /conn?dsn=' ' ids.sql.IDSDriver Informix Dynamic Server jdbc:informix-sqli:// : / :INFORMIXSERVER= com.informix.jdbc.IfxDriver InstantDB (v3.13 and earlier) jdbc:idb: jdbc.idbDriver Insta...

use full links for struts begineers

not only struts... also has some usefull information abt xml, and others java api http://www.allapplabs.com/struts/struts_internationalization.htm

trouble shoot the fedora 9

if the fedora system got hanged , it mean, once the system got login, then after few min, it may got hang, if it hanged and it doesn't allow you to do any operation mean,  you have to reboot the system with by checking the kernal or root system files. to do that,  give the following command  $ sudo touch forcefsck  or  $ sudo touch etc forcefsck then reboot you system.

java examples

use this link you will get samples for the concept you searching.. http://www.exampledepot.com/egs/javax.swing.table/RemoveRow.html
if the table is create with DefaultTableModel, then the following code can be used. i have used and tested... private void removeTable() { if(reportModel.getRowCount() 0) { reportModel.removeRow(0); } }

Struts Tutorial Page

           Difference between Model 1 and Model 2 architecture: Features of MVC1: Html or jsp files are used to code the presentation. To retrieve the data JavaBean can be used. In mvc1 archictecture all the view, control elements are implemented using Servlets or Jsp. In MVC1 there is tight coupling between page and model as data access is usually done using Custom tag or through java bean call. Features of MVC2: The MVC2  architecture removes the page centric property of MVC1 architecture by separating Presentation, control logic and the application state. In MVC2 architecture there is only one controller which receives all the request for the application and is responsible for taking appropriate action in response to each request. Struts framework provides three key components: A  request  handler provided by the application developer that is used to  mapped to a particular URI. A  response  handler which is used to...
Connection pooling in JBOSS with MYSQL Step 1 : copy mysql-connector-java-5.0.7-bin.jar into jboss/server/default/lib or jboss/server/all/lib Step 2 : config the data sources with mysql-ds.xml and config the login-config.xml. Mysql-ds.xml TestSQL jdbc:mysql://localhost:3306/frameworkdb com.mysql.jdbc.Driver root password java/TestSQL Login-config.xml root root password jboss.jca:service=LocalTxCM,name=TestSQL Step 3: then create your connection pooling class in java public String dbConnection(String test) {String str = "";try {Context initContext = new InitialContext();DataSource ds = (DataSource) initContext.lookup("java:TestSQL");Connection con = ds.getConnection();Statement st = con.createStatement();ResultSet rs=st.executeQuery("Select * from authentication");while(rs.next()){str+= "--"+rs.getString(2);}catch (Exception e) {return e.getMessage();}return str;} Step 4 : create the remaining class and deploy it into jboss as war file, in jboss/s...

JDK1.3 Documentation

this jdk document very useful for swt programs... becoz swt gadget is using the jdk version 3.... http://java.sun.com/j2se/1.3/docs/api/

Creating war file using Process and Runtime class........

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CreateWar { public static void main(String[]args) { String temp="c:/createbat.bat";// have command in batch file commands are cd:/ , c:/ , jar -cvf c:/test.war -C c:/lookup // these lines are very important. jar-cvf is used to create the war file. BufferedReader br = executeProgram(temp); String line = new String(); try { while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { System.out.println("The Files are Failed"); e.printStackTrace(); } } private static BufferedReader executeProgram (String pgm) { System.out.println("pgm "+pgm); // creating war file by using the runtime and process class.... Runtime r = Runtime.getRuntime(); ...

jasper report tutorial

see this link for jasper report tutorial..... http://www.docstoc.com/docs/2139263/Jasper-Report-Tutorial http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html

animating progress bar--- creating according to the installation

the following code , which shows hot use the progressbar in the java swing... it uses the swing worker to animate its progress while installing or doing some updations.... refer this link for further doubts... swingworker:http://java.sun.com/docs/books/tutorial/uiswing/concurrency/simple.html /** this class progress is used to create to update the value by swing worker to the process method. this class type is mentioned in the swing worker it has two type of parameter, first shows the done method, and it should be overridden. the second parameter specifies the this call, and u should override the process method.. */ private static class Progress { private final double barValue; Progress(double barValue) { this.barValue = barValue; } } private class processTask extends SwingWorker { @Override protected Void doInBackground() throws Exception { progressBar.setIndeterminate(false); ...