Pandora and last.fm

October 27th, 2006

I like last.fm, I like Pandora and now there’s a way to combine those two. For those of you who might not know pandora check out their site. A very worthily effort to tag music with the results of a style analysis done by professional musicians. They provide a radio service similar to the radio system in last.fm just with the difference that the music played is not influenced by recommendations but by the analysis results of pandora. Works very good after entering some favourite tracks the pandora radio plays a lot of nice music.
Anyway, a guy at Audioscrobbler forums recently presented a way to submit the music heard on pandora to last.fm. To try it out simply go to http://pandorafm.real-ity.com/. You can even download the source from that site and run a server on your own.

I neeeeed this one!

October 26th, 2006

Standalone MP3, WMA, Ogg and even Internet radio Streams via WLAN. Additionally a veerry smooth design…
Santa, please bring me a Squeezebox!

It’s all about stereotypes

October 26th, 2006

Although I hate it if my country is narrowed to Weisswurst, Bier and Schuhplattler i had to post this one. Class A commercial with one of the best Neue Deutsche Welle cover version i’ve ever heard ;)

Zend Framework in subdirs

October 18th, 2006

It took me some time to find this out so maybe it’s useful for you aswell…
I went through the very good tutorial written by Chris Shiflett concerning Zend Framework and was confontend with a little problem. Everything worked fine except the redirection by the Controller objects, I always was redirected to the noRouteAction. The problem is that I installed the application in a vhost subdirectory (http://devserver/subdir/) and it kept redirecting me to the server root. To “fix” this issue one have to make use of the Zend_Controller_RewriteRouter class. The following code snippet shows the usage:

< ?php
include 'Zend.php';

Zend::loadClass('Zend_Controller_Front');
Zend::loadClass('Zend_Controller_RewriteRouter');

$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory(
'/path/to/controller_classes');

Zend::register('controller', $controller);
$router = new Zend_Controller_RewriteRouter();
$controller->setRouter($router);
$controller->dispatch();

?>

Zend Framework

October 18th, 2006

I dealt with PHP first time since ages the last days and did some evaluation work on frameworks. The most promising candidate for future projects is the Zend Framework of which a first stable release is expected during the next weeks.
Most important feature is a MVC implementaion which looks quite similar to Struts. Other neat little features include PDF creation, XMLRPC support, RSS feed handling and many more. The most exciting thing with Zend Framework is the very flexible and “non-invasive” integration opportunity. All features are based on a “can do” basis and it seems to be very easy to integrate 3rd party modules. E.g. integration of Smarty tpl engine and Propel O/R mapping is done in no time (Howtos can be found here and here). I can’t wait for the stable release to come and I’ll definitely give it a try for some upcoming projects. Looks like this could become a Spring for PHP…

Integrate PostgreSQL Data Source in Websphere Application Server

October 12th, 2006

A quite unusual configuration but this short guidance might be useful for some persons (like me):

  1. Open Integrated Solution Console
  2. Navigate to “Resources -> JDBC -> JDBC Providers”
  3. Select the right scope for your application
  4. Click “New”
  5. Select “User-defined” from “Database Type” dropdown
  6. Insert “org.postgresql.ds.PGConnectionPoolDataSource” at “Implementation class name” field
  7. Provide a name and a descriotion of your choice and click “next”
  8. If you haven’t done so before download the JDBC Driver from http://jdbc.postgresql.org/download.html which suits your needs (should be JDBC3 driver for your DB version) and save it at some local library path (e.g. {WAS_HOME}/lib)
  9. Insert the path and jar file name in the next dialog, click “next” and “finish” afterwards
  10. Navigate to “Resources -> JDBC -> Data sources”
  11. Again select the right scope and click “new”
  12. Provide a Data source and a jndi name (e.g. jdbc/myPGdb)
  13. On step 2 dialog select your already created JDBC provider
  14. Just leave step 3 at default values and finish creation, that’s it!

Tested on Websphere Application Server 6.1

J2EE Development with Rational Application Developer

September 29th, 2006

As I have to develop a serious application during my thesis first time ever with Rational Application Developer I was seraching for a good introduction on how to use this mighty tool. I found it, who yould have thought, in an IBM redbook. “Rational Application Developer V6 Programming Guide” is an awesome entrance into the RAD world. Abutted on the classical SUN J2EE tutorial this book describes in detail how to realise a sample banking application with RAD and Websphere Application Server. It covers the realisation of JSP and Servlet-, JSF and SDO-, even Struts based Dynamic Web Application and the integration of EJB Business logic using integrated UML- and other Data modelling tools.
A must read for any person who thinks Eclipse is too much code work ;)

Java Instant Messenger

May 19th, 2006

After some time here’s another code example. I had to write a Java based Instant Messenger for university. The code demonstrates the usage of object serialisation mechanisms in Java and sending streams via TCP and UDP. Features included are Unicast based chatting, Multicast based Chatting and File Transfer via TCP. As it’s just a proof of concept there might be some minur issues when running it and as there was a deadline there are some “unaesthetic” code parts (don’t look at the GUI part, I had to adapt that from my professor ;) ) but the main concepts should be pointed out quite ok. Especially the file transfer via TCP migth be interesting because most of the tutorials one can find just handle Strings or something else.
The complete eclispe project can be found here.

Social Networking via music

April 24th, 2006

A friend of mine just gave me the link to last.fm, a quite funky site which gathers information about the music you play at home automatically and produces charts and even personal radio stations out of them. Haven’t checked out all features like group building, bloging etc. yet but looks like quite a nice project. As you can see on the right they even let you integrate your personal “recently played” list onto your homepage, so for those of you who might be interested this is what I listen to ;)

JDBC and DOM Parser example

October 14th, 2005

The following code snippet demostrates how Java can be used to read database tables and generate a valid xml file out of it. The example uses a DB2 database but should be ported to other databases with small effort. the data is provied by the sample database provided by DB2. Used techniques are JDBC and DOM Parser.

import java.io.FileOutputStream;
import java.sql.*;
import org.apache.crimson.tree.XmlDocument;
import org.w3c.dom.*;


public class DB2Mitarbeiter {


public static void main(String[] args) {
String url = "jdbc:db2://127.0.0.1:50000/SAMPLE";
String SQLString=null;
String lastDep = null;
Element emp = null;
Node lastname, firstname = null;
XmlDocument document = new XmlDocument();
Element dep = document.createElement("department");
Node company = document.createElement("company");
ResultSet rs = null;
// Load Type4 DB Driver
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException");
e.printStackTrace();
}
System.out.println("DB Type 4 Driver loaded.");
// DB connect with url,login and pass
try {
FileOutputStream fo = new FileOutputStream("test.xml");
Connection con = DriverManager.getConnection(url,"username","password");
Statement stmt = con.createStatement();
System.out.println("DB connection established.");
SQLString = "SELECT * FROM DEPARTMENT,EMPLOYEE WHERE EMPLOYEE.WORKDEPT = DEPARTMENT.DEPTNO order by DEPARTMENT.DEPTNO";
//SQLString = "SELECT * FROM DEPARTMENT LEFT JOIN EMPLOYEE ON EMPLOYEE.WORKDEPT = DEPARTMENT.DEPTNO";
rs = stmt.executeQuery(SQLString);
while(rs.next()){
//System.out.println("rs: " + rs.getString("DEPTNO") + " - lastdep: " + lastDep);
if (lastDep == null) {
dep.setAttribute("depid",rs.getString("DEPTNO"));
lastDep = rs.getString("DEPTNO");
emp = document.createElement("employee");
emp.setAttribute("empid", rs.getString("EMPNO"));
lastname = emp.appendChild(document.createElement("lastname"));
lastname.appendChild(document.createTextNode(rs.getString("LASTNAME")));
firstname = emp.appendChild(document.createElement("firstname"));
firstname.appendChild(document.createTextNode(rs.getString("FIRSTNME")));
dep.appendChild(emp);
}
else if (lastDep.equals(rs.getString("DEPTNO"))) {
emp = document.createElement("employee");
emp.setAttribute("empid", rs.getString("EMPNO"));
lastname = emp.appendChild(document.createElement("lastname"));
lastname.appendChild(document.createTextNode(rs.getString("LASTNAME")));
firstname = emp.appendChild(document.createElement("firstname"));
firstname.appendChild(document.createTextNode(rs.getString("FIRSTNME")));
dep.appendChild(emp);
}
else {
company.appendChild(dep);
dep = document.createElement("department");
dep.setAttribute("depid",rs.getString("DEPTNO"));
emp = document.createElement("employee");
emp.setAttribute("empid", rs.getString("EMPNO"));
lastname = emp.appendChild(document.createElement("lastname"));
lastname.appendChild(document.createTextNode(rs.getString("LASTNAME")));
firstname = emp.appendChild(document.createElement("firstname"));
firstname.appendChild(document.createTextNode(rs.getString("FIRSTNME")));
dep.appendChild(emp);
}
lastDep = rs.getString("DEPTNO");
}
document.appendChild(company);
document.write(fo);
fo.close();
} catch (Exception e1) {
System.out.println("Fehler");
e1.printStackTrace();
}
}
}