Recently I was looking to set up a forum. Plenty of them listed here in wikipedia. I went with phpBB.
Atfirst, the Quick Start guide seemed little lengthy. But once started reading, I was able to setup and run the forum in minutes though there was a significant problem I faced while installation. It was setting up the database. I used MySQL with the default storage engine as INNODB. The phpBB installation schema for MySQL created errors if I use the INNODB engine. Tables were not created.
After doing some research, I had to change the storage engine to MYISAM. Then the installation went through and the forum started running good. So if you need to install phpBB with MySQL then you might need to change the storage engine to MYISAM.
If you want the MySQL to use MYISAM all the time, you can set the storage engine in the my.ini file. Command might look like below.
default-storage-engine=MYISAM
Otherwise you can choose to use the MYISAM just for the phpBB installation. And once the installation is over, you can start using the INNODB engine. For this, you can edit the MySQL schema files bundled with phpBB and add the below line as the first line of the schema.
SET storage_engine=MYISAM;
This way the tables will be created without any problem. But I'm not sure if this solves the problem completely. Will post my findings.
Friday, January 23, 2009
Friday, January 9, 2009
Multi database connections
I was using JGrinder as ORM tool for quite some time. Till now, I connected to a single database using JGrinder. And I believed that the JGrinder can connect only one database per JVM. Recently I got a requirement to connect multiple databases in a single JVM. I was not sure it would be possible to do it in JGrinder. So dug it little deeper. Main draw back with JGrinder is that there are not much help documents or forums to talk about it. But after looking at little deeper, I found a way to connect to more than one database in a single JVM using JGrinder. Below is a brief explanation followed by the source code I wrote for it.
JGrinder uses one broker object for each database connection. By default when the following code is executed, a new broker is created with the database details mentioned in the 'fileName' argument.
com.objectwave.appSupport.StartupRoutine.loadDefaults(caller, fileName);
The new broker created will be the default broker by the JGrinder. If more databases need to connected on the fly, broker for each database need to be created and added to the BrokerFactory of JGrinder. When adding the additional brokers, it is necessary to pass a brooker name / tag for the broker, which can be used to identify the broker later to connect to the desired database. The way I used to add additional brokers, is by reading the additional jdbc.ini files. Below is the source code (IniLoader.java) I wrote to load multiple jdbc.ini files. I hope the source code can explain the rest. You can use and distribute this source for free, as long as you abide by the JGrinder licensing terms for its usage.
JGrinder uses one broker object for each database connection. By default when the following code is executed, a new broker is created with the database details mentioned in the 'fileName' argument.
com.objectwave.appSupport.StartupRoutine.loadDefaults(caller, fileName);
The new broker created will be the default broker by the JGrinder. If more databases need to connected on the fly, broker for each database need to be created and added to the BrokerFactory of JGrinder. When adding the additional brokers, it is necessary to pass a brooker name / tag for the broker, which can be used to identify the broker later to connect to the desired database. The way I used to add additional brokers, is by reading the additional jdbc.ini files. Below is the source code (IniLoader.java) I wrote to load multiple jdbc.ini files. I hope the source code can explain the rest. You can use and distribute this source for free, as long as you abide by the JGrinder licensing terms for its usage.
/*
* ========================================================================
* IniLoader
* ========================================================================
*
*/
package com.pinetree.utils.io;
import com.objectwave.persist.BrokerFactory;
import com.objectwave.persist.broker.RDBBroker;
import com.objectwave.persist.properties.BrokerPropertyDetail;
import com.objectwave.persist.properties.BrokerPropertySource;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.Properties;
/**
* IniLoader is used to load multiple jdbc.ini files into the BrokerFactory of
* JGrinder. Loading multiple jdbc.ini files will allow the developer to use
* any of the database defined in the loaded jdbc.ini files from the same JVM.
*
* Here is the sample usage of loading multiple jdbc.ini files.
*
* IniLoader.addDefaultIni(this, "dev_ecpis_jdbc.ini");
* IniLoader.addIni(this, "epics_jdbc.ini", "epics");
*
* Here is an example of connecting to the default database
*
* try {
* ApplicationContainer ac = new ApplicationContainer();
* ac.setAppNo(1234);
* SQLQuery sqlQuery = new SQLQuery(ac);
* VectorresVec = sqlQuery.find();
* if (resVec != null) {
* ac = resVec.get(0);
* System.out.println("Insured Name : " + ac.getInsuredName());
* }
* } catch (Exception e) {
* e.printStackTrace();
* }
*
* Here is an example of connecting to a database other than the default one.
* All needs to be done is to set the broker name to the tag used to add the
* corresponding jdbc.ini file. For example we added epics_jdbc.ini file with a
* epics tag. So to connect to the epics database, it is necessary to set the
* broker name to "epics", as below, before querying it using the SQLQuery object.
*
* try {
* ApplicationContainer ac = new ApplicationContainer();
* ac.setAppNo(1234);
* ac.setBrokerName("epics");
* SQLQuery sqlQuery = new SQLQuery(ac);
* VectorresVec = sqlQuery.find();
* if (resVec != null) {
* ac = resVec.get(0);
* System.out.println("Insured Name : " + ac.getInsuredName());
* }
* } catch (Exception e) {
* e.printStackTrace();
* }
*
*
* @author jerald
*/
public final class IniLoader {
/**
* loads an jdbc.ini file. Any read or write done on the container without
* setting the broker name will use this jdbc.ini file details to connect
* to the database.
*
* @param caller reference of the object that called this method
* @param fileName name of the jdbc.ini file
*
*/
public static void addDefaultIni(Object caller, String fileName) {
com.objectwave.appSupport.StartupRoutine.loadDefaults(caller, fileName);
BrokerFactory.useDatabase();
}
/**
* loads an jdbc.ini file specified in the arguement with the tag name as
* passed in the argument. When the broker name of a container is set to
* the tag passed in this argument, any read or write done on the container
* will happen on the database defined in the jdbc.ini file as passed in the
* argument.
*
* @param caller reference of the object that called this method
* @param fileName name of the jdbc.ini file
* @param tag tag that to be associated with the jdbc.ini file
*/
public static void addIni(Object caller, String fileName, String tag) {
final String URL_TOKEN = "ow.connectUrl";
final String USERNAME_TOKEN = "ow.persistUser";
final String PASSWORD_TOKEN = "ow.persistPassword";
final String DRIVERNAME_TOKEN = "ow.persistDriver";
final String DBIMPL_TOKEN = "ow.databaseImpl";
if (tag == null) tag = fileName;
InputStream inputStream = null;
Properties props = null;
try {
inputStream = ClassLoader.getSystemResourceAsStream(fileName);
} catch (Exception e) {}
if (inputStream == null) {
if (caller instanceof Class) {
inputStream = ((Class) caller).getResourceAsStream(fileName);
} else {
inputStream = caller.getClass().getResourceAsStream(fileName);
}
}
try {
if (inputStream != null) {
BufferedInputStream bis = new BufferedInputStream(inputStream);
props = new Properties();
props.load(bis);
}
} catch (Exception e) {
e.printStackTrace();
}
if (props != null) {
String connectUrl = props.getProperty(URL_TOKEN);
String userName = props.getProperty(USERNAME_TOKEN);
String password = props.getProperty(PASSWORD_TOKEN);
String driverName = props.getProperty(DRIVERNAME_TOKEN);
String dbImpl = props.getProperty(DBIMPL_TOKEN);
if (connectUrl != null && userName != null &&
password != null && driverName != null && dbImpl != null) {
try {
RDBBroker broker = new RDBBroker();
BrokerPropertyDetail bpd = new BrokerPropertyDetail();
bpd.setConnectUrl(connectUrl);
bpd.setPersistUser(userName);
bpd.setPersistPassword(password);
bpd.setPersistDriver(driverName);
bpd.setDatabaseImpl(dbImpl);
BrokerPropertySource bps = new BrokerPropertySource(bpd);
broker.setBrokerPropertySource(bps);
broker.initialize();
BrokerFactory.addStaticBroker(tag, broker);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
Sunday, April 6, 2008
Net Beans 6.1 Beta
After trying so many IDES starting from AdventNet Bean Builder, Emacs, GVIM, Eclipse & Netbeans, I now find the Net Beans more convenient for my development. Recently I downloaded the NetBeans 6.1 Beta. One thing I like most, is the improved Java Script support. Code completion is more relevant now in 6.1 Beta than in 6.0.1. One other thing I liked is the comment section. Previously when I type enter after opening a comment section with a forward slash followed by two stars (/**) a new line with a star followed by a space (* ) will be added by default. It will look like below.

Cursor will be at the position of the hypen in the above line. If I need to close that comment section, I need to type a backspace and a backslash.
Now in 6.1 Beta if I open a comment section and type enter, the comment section will be completed by default, with some intelligence.
1) If a comment section is opened for anything other than class definition or method definition (one exception to this is a method definition with no arguments and which returns void), it is completed as below and the cursor stays at the position of the hypen.

2) If a comment is opened for class definition, it is completed as below.

If a comment is opened for method definition, it is completed with little more smartness.
3) For a method which takes no arguments and returns an object, comment section is closed as

4) For a method that takes some arguments and returns anything but void, comment section is closed as below.

It is something that is not much to do with any functionalities but is a cool function that caught my interest.
Apart from these, one thing I haven't figured out yet is the collapse and expand code. It is not working as it was in 6.0.1. When you start editing the code, suddenly, the collapse / expand is not functioning. When I close the IDE and start again collapse / expand is back. I guess there is something to be fixed. Let me hope for the fix soon.

Cursor will be at the position of the hypen in the above line. If I need to close that comment section, I need to type a backspace and a backslash.
Now in 6.1 Beta if I open a comment section and type enter, the comment section will be completed by default, with some intelligence.
1) If a comment section is opened for anything other than class definition or method definition (one exception to this is a method definition with no arguments and which returns void), it is completed as below and the cursor stays at the position of the hypen.

2) If a comment is opened for class definition, it is completed as below.

If a comment is opened for method definition, it is completed with little more smartness.
3) For a method which takes no arguments and returns an object, comment section is closed as

4) For a method that takes some arguments and returns anything but void, comment section is closed as below.

It is something that is not much to do with any functionalities but is a cool function that caught my interest.
Apart from these, one thing I haven't figured out yet is the collapse and expand code. It is not working as it was in 6.0.1. When you start editing the code, suddenly, the collapse / expand is not functioning. When I close the IDE and start again collapse / expand is back. I guess there is something to be fixed. Let me hope for the fix soon.
Tuesday, October 16, 2007
Not the knowledge but the Passion
8 years back, I used to wonder at the new software products on the market. That was the time Google was trying their hand on the search, and was the time I was looking out for a job as a fresher. I always used to wonder at the hot new software products and the brains behind that. I really thought one should posses really really a super brain to write applications of that kind, I saw then. I developed a small game in 'C using graphics and sound libraries. It was exiting. And I know how complex it is to animate your objects on the screen.
Soon after I joined my first job, I was in the development of an application thats a kind of a mash of GIS (Geographical Information System) and MIS (Management Information System) using Visual Basic, ESRI Map Objects and MS Access. That was out of the concept of my manager who was doing his Phd in Geology then and truly was interesting for me. I felt how great it is to grow stronger and stronger on technical. After that product, I was writing some automation scripts for some applications.
Then moved to a java based firm which I hardly knew about it before joining. I was astonished to see the energy and enthusiasm I found in there. After spending some good time there I had to give up my perceptions. I just not realized but witnessed that it is no the sound technical knowledge that takes you to deliver the world class products. But it is the passion.
And recently, I happened to look at a framework of a software application. Looking at the code, the application seemed to be so complex. But after spending some good time on the code, i'm sure the framework could be more simpler. May be there is a time crunch or other pressures and more for the quality of the development. But beyond that you need to have some passion to write code. This passion can deliver more than your technical skills. I have personally seen some freshers with not much experience deliver more than the experienced people. And i believe it is only out of the passion.
Soon after I joined my first job, I was in the development of an application thats a kind of a mash of GIS (Geographical Information System) and MIS (Management Information System) using Visual Basic, ESRI Map Objects and MS Access. That was out of the concept of my manager who was doing his Phd in Geology then and truly was interesting for me. I felt how great it is to grow stronger and stronger on technical. After that product, I was writing some automation scripts for some applications.
Then moved to a java based firm which I hardly knew about it before joining. I was astonished to see the energy and enthusiasm I found in there. After spending some good time there I had to give up my perceptions. I just not realized but witnessed that it is no the sound technical knowledge that takes you to deliver the world class products. But it is the passion.
And recently, I happened to look at a framework of a software application. Looking at the code, the application seemed to be so complex. But after spending some good time on the code, i'm sure the framework could be more simpler. May be there is a time crunch or other pressures and more for the quality of the development. But beyond that you need to have some passion to write code. This passion can deliver more than your technical skills. I have personally seen some freshers with not much experience deliver more than the experienced people. And i believe it is only out of the passion.
Monday, October 15, 2007
Office Suites - 'm getting bored
Thought the first blog could be an intro. No.
Ok. Microsoft was on the honey moon for some time. As far as I know, Yahoo was there, and Google entered the game of search. Later, 'm not sure of the order, there was Open Office, Google docs, Zoho etc. You could always witness the constant efforts on Web Office suites, on the Google as well as the Zoho. You can see news like this , this etc. Its not only the race between the newbies, but may be a war against MicroSoft Office or its pricing.
I guess, yes, lot of Office suites offers. Recently happened to see eXpresso a new entry into online spread sheet game. Not sure how many new, you can expect more on the same line.
My personal feeling, there is already lot of bloody competition between the biggies. I would like to see something more interesting than the Office suite offerings.
Ok. Microsoft was on the honey moon for some time. As far as I know, Yahoo was there, and Google entered the game of search. Later, 'm not sure of the order, there was Open Office, Google docs, Zoho etc. You could always witness the constant efforts on Web Office suites, on the Google as well as the Zoho. You can see news like this , this etc. Its not only the race between the newbies, but may be a war against MicroSoft Office or its pricing.
I guess, yes, lot of Office suites offers. Recently happened to see eXpresso a new entry into online spread sheet game. Not sure how many new, you can expect more on the same line.
My personal feeling, there is already lot of bloody competition between the biggies. I would like to see something more interesting than the Office suite offerings.
Subscribe to:
Posts (Atom)