Archive for July, 2007

java: testing empty resultset

I really don’t understand why the java.sql.ResultSet don’t provide an isEmpty() method or something similar and it’s true that I rarely need this method, however, sometimes this happen. Here is how I test for empty resultset in java.

ResultSet rs = ...
boolean  emptyRs = true;

while(rs.next()){
   emptyRs = false;
   ...
}

if(emptyRs){
   ...
}

or better (i prefer this one)

ResultSet rs = ...

if(rs.next()){
   do{
      ...
   }while(rs.next());
}else{
   //is empty
}

Comments

Websphere and MySQL datasource

This is about how to create a MySQL datasource in Websphere Test Environment via WSAD (Websphere Studio Application Developer).

Open the server configuration and select the data source tab. Select then the following parameters

  • jdbc typeDatabase type: User-defined
  • JDBC provider type: User-defined JDBC Provider

Then hit next and in the next screen input the following parameters

jdbc settings

  • Name: MySQL
  • Description: blablabla
  • Implementation class name: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
  • class path: remove the existing one and use add external jar pointing to the right MySQL jdbc jar file (mysql-connector-java-5.0.5-bin.jar in my case).

After confirming the JDBC provider, select it from the list and select add next the data source box (just below). Use the Version 5.0 data source, and use next to proceed. Input the following data

Data source settings

  • Name: <name of the jdbc>
  • JNDI Name: jdbc/<name of the jdbc>
  • Data source helper class name: com.ibm.websphere.rsadapter.ConnectJDBCDataStoreHelper

Notice that the helper class is very important. Ensure to use the one specified or things wont works fine.

Now It’s time to input the connection parameters. In the next box (resource properties), after selecting the just created data source, click add until input all those properties:

sample property

  • databaseName: <yourdatabase>?autoReconnect=true (java.lang.String)
  • factory: com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
  • password: <the password>
  • port: 3306 (or your port if installation is customized)
  • serverName: <your server name>
  • user: <the user for connection>

After this, remember to refer to the data source in web.xml and restart the server.

Comments

Debian: integrate firefox and thunderbird (iceweasel and icedove)

This is reported almost everywhere on the net and so here is again.

To make links in thunderbird (icedove) open automatically in firefox (iceweasel) just edit ~/.mozilla-thunderbird/default/<profile>/prefs.js

user_pref("network.protocol-handler.app.http","iceweasel");
user_pref("network.protocol-handler.app.https","iceweasel")

To make mailto links in firefox (iceweasel) open thunderbird (idedove) automatically type about:config in the address bar and edit (or insert if not exists) the following key=>value

network.protocol-handler.app.mailto => icedove

Liam in a comment, point out that should be better to use the debian way (alternatives system) for setting the default browser.

Comments (5)

Bootcamp and windows driver on already partitioned disk

When you install Bootcamp and try to use it on an already partitioned hard disk, it will complain telling you that you have to have a disk with only one partition.

If you just need it to burn the windows cd driver, you don’t need to repartition you hard disk.

CTRL+Click on the Boot Camp Assistant and choose Show Package Contents. Now navigate to Contents -> Resources and you’ll find a DiskImage.dmg. Just burn that disk image and it’s all done.

Comments (2)