1 ago 2009

Socket client, wirte and read

How a Java Socket write and read?
echoSocket = new Socket("taranis", 7);
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
echoSocket.getInputStream()));

The second statement gets the socket's output stream and opens a PrintWriter on it. Similarly, the third statement gets the socket's input stream and opens a BufferedReader on it. The example uses readers and writers so that it can write Unicode characters over the socket.

To send data through the socket to the server, EchoClient simply needs to write to the PrintWriter. To get the server's response, EchoClient reads from the BufferedReader. The rest of the program achieves this.

RSA4WS and WASCE 2.1 integration

How do I do to start a WASCE server from RSA4WS 753?

Pre-Req:
  • IM 1.3.1,
  • RSA4WS 7.5.x installed with default options,
  • WASCE 2.1 (for this example, can be different) installed, you will need the admin user and password.
  1. In RSA4WS, you may need to use the Windows-Preferences dialog, and then in the General-Capabilities option, select the Web Developer options.
  2. Go to Windows-Show View, write Servers in the textbox.
  3. Select Servers.
  4. In the panel, right-click, then New-Server.
  5. If you do not see the WASCE 2.1 or the server that you have installed, you will need to go to this site and http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/ and get the integratetion files. You will use Help-Software Updates and that address to install it, or if you download the files, point to the local folder with it.
  6. Once the installation complete, try again with the New-Server menu. You will need to indicate the folder where WAS is installed.
  7. Use the user and password to fill the panels.
  8. Press finsh, the server should be shown into the servers list.

20 jul 2009

XML XPath with DOM

I was searching for a good tutorial about XML Xpath and I found this one:

http://www.w3schools.com/dom/default.asp

I really liked, because it has a lot of example about all.
Enlace

18 jul 2009

JDBC algoritms

Where to find jdbc examples of almost everything that can be done with that framework:

http://www.roseindia.net/jdbc/jdbc-mysql/index.shtml

JFrame: two ways to close a window

Two way to make a windows that can be closed created with JFrame .
JFrame window= new JFrame("Test");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

or

window.addWindowListener(new WindowAdapter(){
@Override
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});

com.ibm.db2.jcc.am.io: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704

I am taking a master in Software Engineering, our teacher has asked us to use different kinds of DB Manager Systems (DBMS). I tried with IBM DB2, and got different annoying problems.
One of them is the

com.ibm.db2.jcc.am.io: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704

I found some solutions with Google, but none of them helped me in a direct way. This is my code:
Class.forName( "com.ibm.db2.jcc.DB2Driver" );
Connection con = DriverManager.getConnection( "jdbc:db2://server.com:50000/POO", "user", "pass" );

Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM test");

And the error in the last line. We need to indicate the Schema of the table, in other DBMSs it is not needed, but it looks like DB2 does.
So I went to the DB Control Center and I saw that there was a Schema name of the table that I have not noted, then the fix is quick:

ResultSet res = st.executeQuery("SELECT * FROM schema.test");

The schema name of the table was "sergio", so I wrote sergio.test.

ResultSet res = st.executeQuery("SELECT * FROM sergio.test");

And all was solved.


Resources:
http://www.dbtalk.net/ibm-software-db2-udb/db2-error-db2-sql-error-401235.html

16 jul 2009

Cannot connect to keystore JKS

After I have tried to update my Eclipse 3.4.2 in Linux Red Hat 5.0 from an Update site, I got the message:

"Cannot connect to keystore"

"JKS"

I was using the Java version that was included in RH by default the GCJ 1.4, so I have changed it to Java 1.6.4 and the problem disappeared.