Friday, December 2, 2011

Updating Table for Particular Records or Rows

Scenario :  We have to update the particular column of a table for some rows range. Using csv data file.


Address Table







add idadd1add2Street city
100sampsamp2testtstcity
101sampsamp2testtstcity
102sampsamp2testtstcity

Monday, November 28, 2011

Inserting CVS Data to DB Using Db command


Command:
  db2 import from C:\test.csv of del insert into address    (addressId,status,nickname,firstname,lastname,email1)

Imp Points:
  • According to csv file the corresponding coloumns have to be specified for the table.
  • Have to be login to DB with Administrative Privilages.

Thursday, November 3, 2011

Creating Datasource in WAS6.0 for MySql -- RAD7.0

This Post about Creating Mtsql Datasource in RAD 7.0 for WAS 6.0 / WAS 6.1
By default WAS 6.0 does not provide datasource for MySql. We have to create User defined JDBC provider for the My Sql.

The detailed Steps for the Creation.

Step1:
In Admin console select Data Source under Resources.




 


















Step : 3
On the new screen, select User-Defined in Database type field (because WAS doesn’t have MySQL pre-defined), com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource in Implementation Class Name field and MySQL JDBC Provider in Name field.



Step 4: Specify the Jar file path for MySql JDBC connection.


Step 5: Click Finish button.



Step 7: After finishing Again click on the "Test"(what we created just now) Datasource on list of data sources, and Click on the right side JASS-J2C Authentication.


Step 8: Fill the database authentication details like username and password.

Step 9: Just Last Step. We have to fill in some custom properties. like databaseName, URL (of the Database).



Step 10 : in Custom properties look for the URL and enter the Database Access url.







Step 11: now select the authentication we creatted now.

Step 13; now test the connection. its successful.


Retriving Image From Database


// column is column index in ResultSet containing the image,
// we assume that the type is LONGVARBINARY
Image myImage = null;
InputStream stream = rset.getBinaryStream(column);
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
int a1 = stream.read();
while (a1 >= 0) {
output.write((char)a1);
a1 = stream.read();
}
myImage =
Toolkit.getDefaultToolkit().createImage(output.toByteArray());
output.close();
}
catch(Exception e){}