Lazy or Busy
June 1st, 2008
Lately I have been very busy…yea right!!I think If I say I am busy then I’m cheating with myself.Sometimes I am busy but not always.Lets see what I got in my plate.
I have a fulltime job as a Perl programmer then I have responsibility towards my e107 community which I have ignored(but I’m not oblivious)lately.Currently I’m looking forward to master my linux skill.Apart fromall this I have family responsibilities.
I think after full time job these things are good enough to keep me busy but there is a catch to it that If I am really pitching into my task? Answer is NO!!!!.
I have been little lazy or may be exhausted just don’t know yet what is it thats stopping me from doing my things.
E107 has been my community since last 2 yrs and I am committed to it although I’m not doing much right now but I think 16 plugins is good contribution for now.I have certain big projects to start on top of e107 framework.Its hard to say if these projects will ever see daylight or not but I will try my best to get things started.
For those who have been waiting for my new plugins I will say don’t be disappointed at the start of July I will be back with some new plugins and some upgrades to my existing work.
That is it for now.
Hunter
e107 and Me….
August 11th, 2007
Its been a while for me and e107 being together.Almost 1 yr now and I must admit that this past 1 yr was definitely one of my most fruitful years of my life.
So far I have enjoyed working for e107 community as a member of e107 official support team and its an honor for me.My quest for a good CMS ended on e107 in August 2006 and then this quest ended up in a friendship with community and CMS itself.I started making plugins and themes so far I have contributed 16 plugins which counts up to 20 if I include bug fixes and advanced versions.I’m still working on some new plugins and I hope one day I will start theme development also.
Its really hard for me to adjust my time after work being a Perl Programmer and Unix Administrator makes my job more tough and really tiresome but its true that my professional day starts with e107 & ends with e107.Lately I have been maintaining and developing my own site JavaChip.org lately site has been some what successful which means more work for me and more e107 in my professional life.
After working for e107 for 1 year I have come up with an idea to enhance the development of e107 and take it to the next level which means the birth of e107evolution.This is a dream project for me and it will be fun working on it but its just matter of time if this project will see daylight.Idea is still not and I’m dreaming about it hopefully this dream will come true for me…Afterall I’m a dreamer.
Prateek
Â
Neend
August 11th, 2007
Neend
Aaj poori raat nahee so saka,bas cigerette ke dhuye ne kohare kaa ehsaas kara diya.Sota to, per kahin se kano mein kuch goonj raha thaa,jaisee ki koi cheekh raha thaa.Shayad koi Ro raha tha,wo rone ki awaaj kiski thee yahi jananaa chahaa aur utha gaya.
Abhi bhi yahi soch raha hoon ki jo beeta hua kal thaa wo kyaa mere aaj per koi farak daal degaa nahee naheee…………aisaa nahee ho saktaa kam se kam mere saath..phir doosare hi pal sochata hoon ki main kya karoongaa…..kya kuch bhi nahee yaa sab kuch…………nahee nahee….yeh main kya soch raha hoon…huh… so jata hoon kyon bina matlab ki baatein soch raha hoon…bas apnee hi baare mein soch raha hoon us rone ki awaaz ko to main bhool hi gaya……yeh awaaz kya aaj ki hai yaa bahut purani hai….aas pass ki hai yaa kahin……….main khud hi to nahee ro raha hoon….
Haathoon ko tatola to kuch geele pan kaa ehsaas hua…..kya barish ho rahi hai?….phir khud hi muskuraa diyaa…..hahaha main to ghar ke under hoon phir baarish kahan se aayegi…..Dahinaa haath uthaa aur aankhon per swatah hi chala gaya…arey yeh pani aankhon mein kaisee…nahee nahee main ro nahee saktaa….mere to aansoon hi sookh gayee hain…yeh kaisee ho gaya….?
haan sach main to ro raha hoon…..koi baat nahee bahut dino baad royaa chalo accha hi hua…aankhon kaa tinkaa to nikal gaya nahee to bahut dard ho raha thaa……
Sach mein tinkaa hi thaa yaa phir main bahanee khoj raha thaa apne rone ko chupanee ke……
haan sochata hoon yeh bhi………ki aakhir main royaa kyon?
Ek Kahani “Mausi”
August 11th, 2007
“MAUSIâ€
Aaj subah aankh khul gayee,raat mein jaldi so gaya thaa isliye. Waise bhi America mein niyam hi yeh hai ki aap jaldi so jaiye aur jaldi uth jaiye.Parantu main niyom mein bandhaa hua insaan nahee hoon is baat ka mujhe garv bhi hota hai aur kabhi malal aur kabhi jalan bhi.
Jaldi uthaa to Chai peene ki talab hui…..Hindustan se America aaye hue bas abhi 1 din hi to hua thaa.Chai ki adat kahan se jaati.
Anaayaas hi ek chitrapat sa mashtishk mein chalne laga………sab kuch dheere dheere kramshash…ghoomata jaa raha thaa.Wo pehlaa din REC Rourkela mein aur din ki shuruat karne ke liye “Chai†ek amrit si jaan parti.Hamaraa din bhi Chai se shuru hota aur Chai per hi kahatam.
Bas subah ho yaa shaam hum dost Mausi ki dukan per jaa baithatey aur chai ke glass le kar baatein……….Paisee nahee hote to Mausi bade pyar se kehti “Beta baad mein de denaâ€.Kuch apnaa pan thaa usme…..â€Beta .Kabhi Garmi ki Chuttiyon mein khana bhi wahin khaate thee…
Jindagi dheere dheere chalti jaa rahi thee…..kabhi raftaar kam hoti to kabhi bahut tej……
Ek baar Mausi se baat hi baat mein Ghar Baar ke baare mein pooch liya…….
bade hi sehaj bhav se Mausi ne kaha “Beta….ek Laraka hai aur ek Laraki….†maine kaha “Per Mausi koi bhi dikhataa nahee?â€
Mausi ne phir usi saraltaa se kaha†Beta….Laraki Beauty parlour mein kaam karti hai….aur Aspataal mein bhi…isliyee din mein apney “booty palor†rehti hai aur raat mein aspataal mein rehti hai….bahut kaam hota hai naa beta…aur hum gareeb log hain…………†isse pehlee Mausi apni kahani suna paati maine baat ko kaat diya aur pooch baithaa “Mausi Tumhara Larkaa kahan hai?â€
Abki baar kuch Mausi thora ruki jaisey soch rahi ho ki kya jawaab dein…phir kuch soch kar bol padi †Larkaa to beta Cinema haal mein ticket bechataa hai…Hum log to gareeb hain……..â€
Maine ek baar phir baat kaat di jaisee ki main keh raha hoon ki ‘Mausi apni ram kahani mat sunao’ larakpan bhi thaa… aur Engineering college ki hawa bhi.
Ek nasha saa thaa ki haan main engineer hoon…. aur yeh to bas Mausi hi hain…..aur ek soch si dimag mein baith gayee thee ki rehnaa to yahan chaar saal hi hai aur waisee bhi duniya mein bahut log gareeb hain kis kis kaa dukh sunoo aur kis kis kaa dukh door karoon.Bas apni jindagi jiye jao…
Samay ke saath saath mera 3rd year bhi aa gaya….par in kuch mahino mein ek badalav maine dekha Mausi ki dukan per ….. koi daru pee kar har samay wahin padaa rehtaa thaa….naa kuch boltaa naa hi kuch kehtaa…..haan Mausi usko le kar thora pareshaan jaroor rehti …………per kise Mausi ki parwaah thee…..hamein to ek aur saathi mil gaya Daru supply karnee ke liye….apni to chal nikali….Mausi ki dukan per ab Chai ke saath Daru bhi piyo aur Pilao…
Mausi sab dekhati par kuch kehti naa thi…shayad usko bhi khushi thee ki ‘chalo is nakara ke Chaltey chai to bikane lagi…..’
In 3 saalon mein Mausi ki dukan kafi badi ho gayee thee….par maine laraki ko aaj tak nahee dekhaa thaa….aur naa hi Larake baare mein jaaantee thee… aur kaun itana sochata bhi thaa apni hostel ki fast life ke chalte…Bas hamara naya saathi jiskaa naam hamane “Tulliram†rakhaa thaa…hamein daru deta aur kabhi hum usey daru dete……bas aisee hi yeh kram chaltaa raha…..
Ab hamaraa 4th aur aakhiri saal thaa…. idhar kuch dino se college kaa mahaul garam thaa…kyon ki kuch larake der raat ko bahar se aaate pakara gayee thee…. der raat mein bahar se…………baat kuch hajam nahee hoti,kyon ki college sabhi larake aksaar der raat tak bahar rehte thee aur khaa pee kar aatee thee.Kuch to thaa is mamalee mein….Jab thora pata kiya to maloom chala ki wo sab…………………….yeh samjhane ki jaroorat nahee hai ki kya hua……..
Phir wahi subah aur wahi chai ki dukan….is baar apnee ek dost jo ki raat wali ghatana mein shamil thaa ke saath gaya……is baar chai dene ek laraki bahar aayee….
laraki ne kaha†Mayee ki tabiyat kharaab hai…†aur laraki ne chai hamein pakraa di.
Hum chai pee kar uthey aur mera dost kuch jyadaa hi tej chalnee laga….karan poocha to pata chala ki yeh wahi laraki……Mera dimag sayein sayein karnee laga…Sannate goojane lage kano mein……â€Mausi ki baat …Beauty Parlour….Asptaal…kya yeh sab jhoot hai…..main usey Mausi kehtaa raha aaj tak….nahee nahee itana badaa dhokhaa…ander kuch aur bahar se kuch….†Sab kuch to soch dala maine jitana bura soch saktaa thaa sab kuch….Ab yeh nishachay kar liya thaa ki ab us dukan per chai nahee piyongaa…isliye nahee ki chai gundi ho gayee yaa wo laraki ….. parantu ek soch thee ki “Mausi†kaise kahoongaa………..
Shaam hui aur sabhi dost ek baar phir usi taraf nikal pade aur is baar doosari chai ki dukan….aur Mausi ki dukan ki taraf aisee dekha jaisee ki keh raha hoon….dekho ab tumhe poochata bhi nahee…..Kuch hi der baad dekhata hoon 4-5 aadmi……kuch galiyaan……aur Mausi ki….dukan ab ek Khandahar ban chuki thee…..poochane per pata chala ki jameen kisi aur ki thee aur Mausi ne uskaa kiraya nahee diyaa thaa 1 saal se…………kyon ki jo paisee thee wo sab larake kaa ilaaj karane mein kharch ho gaye…. “larake kaa ilaaj….? Arey larakaa to khud hi kamataa hai….†doosare chai wale se maine kaha…..jawab aayaa arey kahan bhaiyaa…..kis duniyaa mein rehtee ho….main poochaâ€Kyon…?†phir se jawab “Jo aap logon ke saath daru peeta thaa naa wahi to iskaa larkaa thaa…. aur ab to wo Mar bhi gaya 1 saal ho gayee babu….†Is baar main phir soch mein pad gaya….â€Mausi ne jhoot kyon kaha…..?†phir apney aap hi soch ne ek karwat li aur kuch samajh aanee laga ander chadhaa pardaa thoraa hatataa dikh raha thaa….â€Aakhir Mausi bhi ek Maa thee usey bhi apnee parivar ko acchaa dekhana kaa hak hai….to kya hua agar wo GAREEB………..bas Gareeb…………haan Gareeb yahi to Mausi har baat ke baad kehti thee…….
jo main sunana nahee chahtaa thaa………….kisi naa kisi bahanee taal detaa thaa Mausi ki baat…..†Ab nafrat ki jagah glani ne leli thee……thora dukh bhi hua.
Achanak kuch jalane ki gandh se main soch se jaga aur chai kaa pani dekhane kitchen mein chal diya…..per under ek santosh thaa ……………… is baat kaa ki maine usey galat naam nahee diyaa thaa………jo ki Maa ke samaan thaa……………….MAUSI.
“Prateekâ€
Â
JDBC Code Examples
October 11th, 2006
Â
Accessing Databases with JDBC
JDBC has two parts: the JDBC Core Application Programming Interface (API) and the JDBC Optional Package API.
The java.sql Package
The java.sql package provides the API for accessing and processing data in a data source. The most important members of the java.sql package are as follows:
• The DriverManager class
• The Driver interface
• The Connection interface
• The Statement interface
• The ResultSet interface
• The PreparedStatement interface
• The ResultSetMetaData interface
The DriverManager Class
The DriverManager class provides static methods for managing JDBC drivers. Each JDBC driver you want to use must be registered with the DriverManager. The JDBC driver of the database to which you want to connect is supplied either by the database vendor or a third party.
try {
Class.forName(”JDBC.driver”);
}
catch (ClassNotFoundException e) {
// driver not found
}
In this case, JDBC.driver is the fully qualified name of the JDBC driver class. This name can be found in the documentation accompanying the JDBC driver.
The DriverManager class’s most important method is getConnection that returns a java.sql.Connection object. This method has three overloads whose signatures are as follows:
public static Connection getConnection(String url)
public static Connection getConnection(String url, Properties info)
public static Connection getConnection(String url, String user, String password)
The Driver Interface
The Driver interface is implemented by every JDBC driver class. The driver class itself is loaded and registered with the DriverManager, and the DriverManager can manage multiple drivers for any given connection request. In the case where there are multiple drivers registered, the DriverManager will ask each driver in turn to try to connect to the target URL.
The Connection Interface
The Connection interface represents a connection to the database. An instance of the Connection interface is obtained from the getConnection method of the DriverManager class.
close
The close method immediately closes and releases a Connection object instead of waiting for it to be released automatically. Its signature is as follows:
public void close() throws SQLException
isClosed
You use this method to test whether the Connection object is closed. The signature of this method is as follows:
public boolean isClosed() throws SQLException
createStatement
The createStatement method is used to create a Statement object for sending SQL statements to the database. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement object.
This method has two overloads with the following signatures:
public Statement createStatement() throws SQLException
public Statement createStatement (int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement
You use the prepareStatement method to create a PreparedStatement object. Its signature is as follows:
public PreparedStatement prepareStatement()throws SQLException
getAutoCommit
The getAutoCommit method returns a boolean specifying the current auto-commit state. The signature of this method is as follows:
public boolean getAutoCommit() throws SQLException
This method returns true if auto-commit is enabled and false if auto-commit is not enabled. By default, auto-commit is enabled.
setAutoCommit
The setAutoCommit method sets the auto-commit state of the Connection object. Its signature is as follows:
public void setAutoCommit(boolean autocommit) throws SQLException
commit
You use the commit method to commit a transaction. The signature of this method is as follows:
public void commit() throws SQLException
rollback
You use the rollback method to roll back a transaction. Its signature is as follows:
public void rollback() throws SQLException
The Statement Interface
You use the statement interface method to execute an SQL statement and obtain the results that are produced. The two most important methods of this interface are executeQuery and executeUpdate.
executeQuery
The executeQuery method executes an SQL statement that returns a single ResultSet object. Its signature is as follows:
public ResultSet executeQuery(String sql) throws SQLException
executeUpdate
The executeUpdate method executes an insert, update, and delete SQL statement. The method returns the number of records affected by the SQL statement execution, and its signature is as follows:
public int executeUpdate(String sql)
The ResultSet Interface
The ResultSet interface represents a table-like database result set. A ResultSet object maintains a cursor pointing to its current row of data. Initially, the cursor is positioned before the first row. The following are some important methods of the ResultSet interface.
isFirst
The isFirst method indicates whether the cursor points to the first record in the ResultSet. Its signature is as follows:
public boolean isFirst() throws SQLException
isLast
The isLast method indicates whether the cursor points to the last record in the ResultSet. Its signature is as follows:
public boolean isLast() throws SQLException
next
The next method moves the cursor to the next record, returning true if the current row is valid and false if there are no more records in the ResultSet object. The method’s signature is as follows:
public boolean next() throws SQLException
getMetaData
The getMetaData method returns the ResultSetMetaData object representing the meta data of the ResultSet. The signature of the method is as follows:
public ResultSetMetaData getMetaDate() throws SQLException
In addition to the previous methods, you can use several getXXX methods to obtain the value of the specified column in the row pointed by the cursor. In this case, XXX represents the data type returned by the method at the specified index, and each getXXX method accepts the index position of the column in the ResultSet. The column index 1 indicates the first column. The signature of this method is as follows:
public XXX getXXX(int columnIndex) throws SQLException
For example, the getString method has the following signature and returns the specified cell as String:
public String getString(int columnIndex) throws SQLException
The PreparedStatement Interface
The PreparedStatement interface extends the Statement interface and represents a precompiled SQL statement. You use an instance of this interface to execute efficiently an SQL statement multiple times.
The ResultSetMetaData Interface
The ResultSetMetaData interface represents the meta data of a ResultSet object. The following sections introduce the most important methods.
Metadata: contains information about information
getColumnCount
The getColumnCount method returns the number of columns in the ResultSet whose meta data is represented by the ResultSetMetaData object. Its signature is as follows:
public int getColumnCount() throws SQLException
getColumnName
The getColumnName method returns the column name as the specified column index. Its signature is as follows:
public String getColumnName(int columnIndex) throws SQLException
The first column is indicated by index number 1.
Four Steps to Getting to the Database
1. Load the JDBC database driver.
2. Create a connection.
3. Create a statement.
4. Create a resultset, if you expect the database server to send back some data.
Step 1: Load a JDBC Database Driver
Type 1 drivers: are drivers that provide access to ODBC drivers and also are called the JDBC-ODBC Bridge driver
Type 2 drivers: are drivers written in part Java and part native API to convert JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.
Type 3 drivers: are drivers written to use the network protocol to translate JDBC API calls into a DBMS-independent net protocol, which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases.
Type 4 drivers: are pure Java. They are written to use the native protocol to convert JDBC technology calls into the network protocol directly used by DBMSs. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access.
Step 2: Creating a Connection
After you register a JDBC driver with the DriverManager, you can use it to get a connection to the database. In JDBC, a database connection is represented by the java.sql.Connection interface. You use the DriverManager class’s getConnection method to obtain a Connection object.
public static Connection getConnection(String url, String user, String password) throws SQLException
The url part is the trickiest element in this method. The url is of this syntax:
jdbc:subprotocol:subname
If you are using a JDBC-ODBC bridge driver, the subprotocol is “odbc” and the subname is the Data Source Name (DSN) for that database. For instance, for a DSN called MarketingData, your URL will be:
jdbc:odbc:MarketingData
If you want to connect to a MySQL database, the subprotocol part is “mysql” and the subname part should be given the name of the machine and the database. For example, for a database named Fred, use the following:
jdbc:mysql///Fred
Step 3: Creating a Statement
Its signature is as follows:
public Statement createStatement() throws SQLException
Therefore, to create a Statement object from an open Connection object, you write the following:
// connection is an open Connection object
Statement statement = connection.createStatement();
Next, use the methods in the Statement class interface to manipulate your data or data structure. You will use two important methods: executeUpdate and executeQuery. The signatures for both methods are as follows:
public int executeUpdate(String sql) throws SQLException
public ResultSet executeQuery(String sql) throws SQLException
The executeUpdate method executes an SQL INSERT, UPDATE, or DELETE statement and also data definition language (DDL) statements to create, drop, and alter tables. This method returns the row count for INSERT, UPDATE, or DELETE statements or returns 0 for SQL statements that return nothing
executeQuery method executes an SQL SELECT statement that returns data. The ResultSet object contains the data produced by the given query. This method never returns a null.
Step 4: Creating a ResultSet
A ResultSet is the representation of a database table that is returned from a Statement object. A ResultSet object maintains a cursor pointing to its current row of data. When the cursor is first returned, it is positioned before the first row. To access the first row of the ResultSet, you need to call the next() method of the ResultSet interface.
on. getShort You use the getInt method, for example, to obtain the value of the designated column in the current row of this ResultSet object as an int in the Java programming language. The getLong gets the cell data as a long, etc. The most commonly used method is getString, which returns the cell data as a String. Using getString is preferable in many cases because you don’t need to worry about the data type of the table field in the database.
The getString method, similar to other getXXX methods, has two overloads that allow you to retrieve a cell’s data by passing either the column index or the column name. The signatures of the two overloads of getString are as follows:
public String getString(int columnIndex) throws SQLException
public String getString(String columnName) throws SQLException
String sql = “SELECT FirstName, LastName FROM Users”;
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
System.out.println(resultSet.getString(1) + “:” + resultSet.getString(”LastName”) );
}
resultSet.close();
Always call the close method to explicitly close the ResultSet object.
Example
try {
Class.forName(”com.internetcds.jdbc.tds.Driver”);
Connection con = DriverManager.getConnection(
“jdbc:freetds:sqlserver://Lampoon/Registration”,
“sa”, ” s3m1c0nduct0r”);
System.out.println(”got connection”);
Statement s = con.createStatement();
String sql =
“INSERT INTO UserReg VALUES (’a', ‘b’, ‘12/12/2001′, ‘f’)”;
s.executeUpdate(sql);
sql = “SELECT FirstName, LastName FROM Users”;
ResultSet rs = s.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getString(1) + ” ” + rs.getString(2));
}
rs.close();
s.close();
con.close();
}
catch (ClassNotFoundException e1) {
System.out.println(e1.toString());
}
catch (SQLException e2) {
System.out.println(e2.toString());
}
catch (Exception e3) {
System.out.println(e3.toString());
}
Connection Pooling
When the application starts, a certain number of Connection objects are created and stored in a pool. When a database client, such as a servlet, needs to use a Connection object, it does not create the object but instead requests one from the pool. When the client is finished with it, the Connection object is returned to the pool.
Transactions
By default, a Connection object’s auto-commit state is true, meaning that the database is updated when an SQL statement is executed.
Next Page »