Wednesday, June 23, 2010

178: ISAM error: Database is locked; pending change to logging mode.

Normally this error indicates that the logging mode of the database has changed using the ondblog command.
Normally making a level 0 archive solves the problem

Thursday, July 31, 2008

System configuration in solaris

Running of "/usr/sbin/prtconf" will give the System configuration...

To filter Details you can use grep
ex:
/usr/sbin/prtconf | grep Memory

ResultSet Behaviour in Java

A ResultSet cursor is initially positioned before the first row;
the first call to the method next makes the first row the current row;
the second call makes the second row the current row, and so on.
If an input stream is open for the current row, a call to the method next will implicitly close it.
A ResultSet object's warning chain is cleared when a new row is read.
Returns: true if the new current row is valid; false if there are no more rows
Throws: SQLException if a database access error occurs

smple prgram to read from console in java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.text.ParseException;

public class ReadDoubleFromConsole {
public static void main(String[] args) {
System.out.println("Enter a number.");
double numberFromConsole;
try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
DecimalFormat df = new DecimalFormat();
Number n = df.parse(s);
numberFromConsole = n.doubleValue();
} catch (IOException e) {
numberFromConsole = 0;
} catch (ParseException e) {
numberFromConsole = 0;
}
System.out.println(numberFromConsole );
}
}

Wednesday, July 30, 2008

From banks of Godavari to Google on wheel chair






Naga Naresh Karutura has just passed out of IIT Madras in Computer Science and has joined Google in Bangalore.
You may ask, what's so special about this 21-year-old when there are hundreds of students passing out from various IITs and joining big companies like Google?
Naresh is special. His parents are illiterate. He has no legs and moves around in his powered wheel chair. (In fact, when I could not locate his lab, he told me over the mobile phone, 'I will come and pick you up'. And in no time, he was there to guide me)
Ever smiling, optimistic and full of spirit; that is Naresh. He says, "God has always been planning things for me. That is why I feel I am lucky."
Read why Naresh feels he is lucky.

Childhood in a village
I spent the first seven years of my life in Teeparru, a small village in Andhra Pradesh, on the banks of the river Godavari. My father Prasad was a lorry driver and my mother Kumari, a house wife. Though they were illiterate, my parents instilled in me and my elder sister (Sirisha) the importance of studying.
Looking back, one thing that surprises me now is the way my father taught me when I was in the 1st and 2nd standards. My father would ask me questions from the text book, and I would answer them. At that time, I didn't know he could not read or write but to make me happy, he helped me in my studies!
Another memory that doesn't go away is the floods in the village and how I was carried on top of a buffalo by my uncle. I also remember plucking fruits from a tree that was full of thorns.
I used to be very naughty, running around and playing all the time with my friends. I used to get a lot of scolding for disturbing the elders who slept in the afternoon. The moment they started scolding, I would run away to the fields!
I also remember finishing my school work fast in class and sleeping on the teacher's lap!

Life without legs
I don't think my life changed dramatically after I lost both my legs. Because all at home were doting on me, I was enjoying all the attention rather than pitying myself. I was happy that I got a lot of fruits and biscuits.










The day I reached my village, my house was flooded with curious people; all of them wanted to know how a boy without legs looked. But I was not bothered; I was happy to see so many of them coming to see me, especially my friends!
All my friends saw to it that I was part of all the games they played; they carried me everywhere.
God's hand
I believe in God. I believe in destiny. I feel he plans everything for you. If not for the accident, we would not have moved from the village to Tanuku, a town. There I joined a missionary school, and my father built a house next to the school. Till the tenth standard, I studied in that school.
If I had continued in Teeparu, I may not have studied after the 10th. I may have started working as a farmer or someone like that after my studies. I am sure God had other plans for me.
My sister, my friend
When the school was about to reopen, my parents moved from Teeparu to Tanuku, a town, and admitted both of us in a Missionary school. They decided to put my sister also in the same class though she is two years older. They thought she could take care of me if both of us were in the same class. My sister never complained.
She would be there for everything. Many of my friends used to tell me, you are so lucky to have such a loving sister. There are many who do not care for their siblings.
She carried me in the school for a few years and after a while, my friends took over the task. When I got the tricycle, my sister used to push me around in the school.
My life, I would say, was normal, as everyone treated me like a normal kid. I never wallowed in self-pity. I was a happy boy and competed with others to be on top and the others also looked at me as a competitor.
Inspiration
I was inspired by two people when in school; my Maths teacher Pramod Lal who encouraged me to participate in various local talent tests, and a brilliant boy called Chowdhary, who was my senior.
When I came to know that he had joined Gowtham Junior College to prepare for IIT-JEE, it became my dream too. I was school first in 10th scoring 542/600.
Because I topped in the state exams, Gowtham Junior College waived the fee for me. Pramod Sir's recommendation also helped. The fee was around Rs 50,000 per year, which my parents could never afford.
Moving to a residential school
Living in a residential school was a big change for me because till then my life centred around home and school and I had my parents and sister to take care of all my needs. It was the first time that I was interacting with society. It took one year for me to adjust to the new life.
There, my inspiration was a boy called K K S Bhaskar who was in the top 10 in IIT-JEE exams. He used to come to our school to encourage us. Though my parents didn't know anything about Gowtham Junior School or IIT, they always saw to it that I was encouraged in whatever I wanted to do. If the results were good, they would praise me to the skies and if bad, they would try to see something good in that. They did not want me to feel bad.
They are such wonderful supportive parents.
Life at IIT- Madras
Though my overall rank in the IIT-JEE was not that great (992), I was 4th in the physically handicapped category. So, I joined IIT, Madras to study Computer Science.
Here, my role model was Karthik who was also my senior in school. I looked up to him during my years at IIT- Madras.
He had asked for attached bathrooms for those with special needs before I came here itself. So, when I came here, the room had attached bath. He used to help me and guide me a lot when I was here.
I evolved as a person in these four years, both academically and personally. It has been a great experience studying here. The people I was interacting with were so brilliant that I felt privileged to sit along with them in the class. Just by speaking to my lab mates, I gained a lot.



Words are inadequate to express my gratitude to Prof Pandurangan and all my lab mates; all were simply great. I was sent to Boston along with four others for our internship by Prof Pandurangan. It was a great experience.
Joining Google R&D
I did not want to pursue PhD as I wanted my parents to take rest now.
Morgan Stanley selected me first but I preferred Google because I wanted to work in pure computer science, algorithms and game theory.
I am lucky
Do you know why I say I am lucky?
I get help from total strangers without me asking for it. Once after my second year at IIT, I with some of my friends was travelling in a train for a conference. We met a kind gentleman called Sundar in the train, and he has been taking care of my hostel fees from then on.
I have to mention about Jaipur foot. I had Jaipur foot when I was in 3rd standard. After two years, I stopped using them. As I had almost no stems on my legs, it was very tough to tie them to the body. I found walking with Jaipur foot very, very slow. Sitting also was a problem. I found my tricycle faster because I am one guy who wants to do things faster.
One great thing about the hospital is, they don't think their role ends by just fixing the Jaipur foot; they arrange for livelihood for all. They asked me what help I needed from them. I told them at that time, if I got into an IIT, I needed financial help from them. So, from the day I joined IIT, Madras, my fees were taken care of by them. So, my education at the IIT was never a burden on my parents and they could take care of my sister's Nursing studies.
Surprise awaited me at IIT
After my first year, when I went home, two things happened here at the Institute without my knowledge.
I got a letter from my department that they had arranged a lift and ramps at the department for me. It also said that if I came a bit early and checked whether it met with my requirements, it would be good.
Second surprise was, the Dean, Prof Idichandy and the Students General Secretary, Prasad had located a place that sold powered wheel chairs. The cost was Rs 55,000. What they did was, they did not buy the wheel chair; they gave me the money so that the wheel chair belonged to me and not the institute.
My life changed after that. I felt free and independent.
That's why I say I am lucky. God has planned things for me and takes care of me at every step.
The world is full of good people
I also feel if you are motivated and show some initiative, people around you will always help you. I also feel there are more good people in society than bad ones. I want all those who read this to feel that if Naresh can achieve something in life, you can too.

sample program to opoen open office spread sheet from Java

//package SpreadSheetAPI;

import com.sun.star.beans.PropertyValue;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNamed;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.sheet.XCellRangeAddressable;
import com.sun.star.sheet.XSheetCellCursor;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XUsedAreaCursor;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.table.XCell;
import com.sun.star.text.XText;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import spreadsheetUtilities.*;

/**
* A Sample for access xls/ods from OOo API
* Requirement:
* 1.Install OOo 2.0
* 2.Add jars to your project.(In OOoInstallPath\program\classes)
* at least those jars must be included : juh.jar,jurt.jar,ridl.jar,unoil.jar
*
**/
public class ReadSheetCellsSample {

private XComponentContext xRemoteContext = null;

private XMultiComponentFactory xRemoteServiceManager = null;

public ReadSheetCellsSample() {
}

public static void main(String[] args) {
ReadSheetCellsSample helloTextTableShape1 = new ReadSheetCellsSample();
try {
helloTextTableShape1.outSheets();
} catch (java.lang.Exception e) {
e.printStackTrace();
} finally {
System.out.println("...End");
System.exit(0);
}

}

protected void outSheets() throws java.lang.Exception {
// xls,service
XComponent xCalcComponent = loadComponent("D:\\Temp\\sample.ods");

XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument) UnoRuntime
.queryInterface(XSpreadsheetDocument.class, xCalcComponent);

com.sun.star.sheet.XSpreadsheets xSheets = xSpreadsheetDocument.getSheets();
// XIndexAccesssheet
XIndexAccess xIndexedSheets = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xSheets);

int sheetCount = xIndexedSheets.getCount();
System.out.println("Sheet Count:" + sheetCount);

for (int i = 0; i < sheetCount; i++) {
Object sheet = xIndexedSheets.getByIndex(i);
XSpreadsheet xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
XSpreadsheet.class, sheet);
// XNamedSheet
XNamed xSheetName = (XNamed) UnoRuntime.queryInterface(
XNamed.class, sheet);
System.out.println("Sheet " + i + ":" + xSheetName.getName());

outSheet(xSheet);
}
//To wait in the application..
//wait(5000);
//CalctryCalcsoffice.bin?soffice.exe
//xCalcComponent.dispose();
}

protected void outSheet(XSpreadsheet xSheet) throws Exception {

//Cursor
XSheetCellCursor xCursor = xSheet.createCursor();

// XUsedAreaCursor,
XUsedAreaCursor xUsedCursor = (XUsedAreaCursor) UnoRuntime
.queryInterface(XUsedAreaCursor.class, xCursor);
xUsedCursor.gotoStartOfUsedArea(false);
xUsedCursor.gotoEndOfUsedArea(true);
XCellRangeAddressable xSheetRange = (XCellRangeAddressable) UnoRuntime
.queryInterface(XCellRangeAddressable.class, xCursor);
CellRangeAddress cellRangeAddress = xSheetRange.getRangeAddress();

System.out.println(cellRangeAddress.StartRow);
System.out.println(cellRangeAddress.StartColumn);
System.out.println(cellRangeAddress.EndRow);
System.out.println(cellRangeAddress.EndColumn);
int rowCount = cellRangeAddress.EndRow + 1;
int colCount = cellRangeAddress.EndColumn + 1;

System.out.println("row count:" + rowCount + ",column count" + colCount);

for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < colCount; col++) {
System.out.println("Column : "+ col + " Row : "+row);
XCell cell = xCursor.getCellByPosition(col, row);
String formula = cell.getFormula();
XText xText = (XText) UnoRuntime.queryInterface(XText.class,
cell);
String text = xText.getString();
System.out.println("\t" + row + "," + col + "," + formula + ","
+ text);
cell.setValue(219);
cell.setFormula("=sum(A1,A2)");

}
}
}

protected XComponent loadComponent(String filePath)
throws java.lang.Exception {
String loadUrl = "file:///" + filePath;

xRemoteServiceManager = this.getRemoteServiceManager();
Object desktop = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", xRemoteContext);

XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime
.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] loadProps = new PropertyValue[3];

loadProps[0] = new PropertyValue();
loadProps[0].Name = "ReadOnly";
loadProps[0].Value = new Boolean(true);

loadProps[1] = new PropertyValue();
loadProps[1].Name = "DocumentTitle";
loadProps[1].Value = "PMGUI Report";

//Default all macros will be Run...
loadProps[2] = new PropertyValue();
loadProps[2].Name = "MacroExecutionMode";
loadProps[2].Value = 4;

//loadProps[2] = new PropertyValue();
//loadProps[2].Name = "Hidden";
//loadProps[2].Value = new Boolean(true);

//loadProps[1] = new PropertyValue();
//loadProps[1].Name = "FilterName";
//loadProps[1].Value = "writer_pdf_Export";

return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0,loadProps);
}

protected XMultiComponentFactory getRemoteServiceManager()
throws java.lang.Exception {
if (xRemoteContext == null && xRemoteServiceManager == null) {
try {
// First step: get the remote office component context
xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
xRemoteServiceManager = xRemoteContext.getServiceManager();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
return xRemoteServiceManager;
}

}

JDBC connectivity to informix

To Run A JDBC program , following steps should be followed
1. Install the appropriate JDBC libraries according to ur Operating System/System configuration
2. Need to finalize the URL to connect to the Database
3. need to include the Directory of the JDBC library to the "CLASSPATH" environment varaiable.
4. Run the Program.

We can get appropriate JDBC driver from different Vendors.. following link will give the Details about the which Driver to Choose and all
http://developers.sun.com/product/jdbc/drivers
Download the appropriate Driver and install.

The main thing in running a JDBC program is deciding the Conncetion URL.

The URL string looks like this:
"jdbc:informix-sqli://hostname:port_num/database_name:informixserver=server;user=user;password=pwd"

where jdbc is the main protocol and informix-sqli is the sub protocol
and all other fields are self explanatory

example link :
jdbc:informix-sqli://scsibox:1526/my_data:informixserver=ol_scsibox;user=informix;password=Informix

use the Driver name as "com.informix.jdbc.IfxDriver"

so remaining all we can find from SUN help... i.e.. different classess and all..


one sample program:

import java.sql.*;
import java.io.*;
import java.util.*;
import java.lang.*;
import sqlj.runtime.ref.DefaultContext;

public class ConnectionManager
{
String DRIVER = null ; //JDBC Driver class
String DBURL = null ; //Database URL
String PWD = null, UID = null ; //Password for database account
DefaultContext ctx;
Statement stmt;
public Connection conn;
public Driver d;
String Query = null;
ResultSet rs = null;
int rc = -1;

//This block has to be changed and ConnectionManager.java recompiled

//Assign Default values for Driver loading...
public ConnectionManager(){
DRIVER = "com.informix.jdbc.IfxDriver";
DBURL = "jdbc:informix-sqli://10.128.96.66:5030/omcdb:informixserver=omc_sys1;"+
"username=informix;password=informix";
UID = "informix";
PWD = "informix";

//Establish connection
newConnection();
}

public ConnectionManager(String sDriver, String sDBUrl,String sUID,String sPWD){
DRIVER = sDriver;
DBURL = sDBUrl;
UID = sUID;
PWD = sPWD;

//Establish connection
newConnection();
}

public void newConnection()
{
try
{
d = (Driver)(Class.forName( DRIVER ).newInstance());
DriverManager.registerDriver(d);
System.out.println("Informix Driver Successfully Created....");
}
catch (Exception e)
{
System.err.println( "Could not load driver: " + DRIVER ) ;
System.err.println(e) ;
System.exit(1) ;
}

try
{
conn = DriverManager.getConnection (DBURL, UID, PWD);
//conn.setAutoCommit(false); // Turn AutoCommit off
System.out.println("Created Connection successfully to the Database");
}
catch (SQLException exception)
{
System.out.println("Error: could not get a connection");
System.err.println(exception) ;
exception.printStackTrace();
System.exit(1);
}
}


public void setSQLQuery(String query){
Query = query;
}

//This Method is only to execute statments which dont return Result set...
public int executeQuery(){
rc = -1;
try{
stmt = conn.createStatement();
rc = stmt.executeUpdate(Query);
System.out.println("Transaction successful .. Updated Rows : " + rc);
}catch(SQLException e){
System.out.println("FAILED: execution failed - statement: " + Query);
System.out.println("ERROR: " + e.getMessage());
e.printStackTrace();
}

try{
stmt.close();
}catch(SQLException e){
}

return rc;
}

//This shoulb be used with select like queries... which result Resultset...
public ResultSet fetchResultset(){
rs = null;
try{
stmt = conn.createStatement();
rs = stmt.executeQuery(Query);
System.out.println("Fetched Result Set Successfully");
}catch(SQLException e){
System.out.println("FAILED: execution failed - statement: " + Query);
System.out.println("ERROR: " + e.getMessage());
e.printStackTrace();
}

try{
stmt.close();
}catch(SQLException e){
}

return rs;
}

public void closeResultset(){
try{
rs.close();
rs = null;
}catch(SQLException e){
}

}

public DefaultContext initContext(){
ctx = DefaultContext.getDefaultContext();

if (ctx == null) {
try {
newConnection();
ctx = new DefaultContext(conn);
}
catch (SQLException e) {
System.out.println("Error: could not get a default context");
System.err.println(e) ;
System.exit(1);
}
DefaultContext.setDefaultContext(ctx);
}
return ctx;
}
}

executing command in Java

    try {
// Execute a command without arguments
String command = "ls";
Process child = Runtime.getRuntime().exec(command);

// Execute a command with an argument
command = "ls /tmp";
child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
If an argument contain spaces, it is necessary to use the overload that requires the command and its arguments to be supplied in an array:
    try {
// Execute a command with an argument that contains a space
String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
}

Friday, June 20, 2008

Mozilla investigates critical Firefox 3.0 bug

June 19, 2008 (Computerworld) Mozilla Corp. today downplayed a threat posed by the first vulnerability reported for Firefox 3.0, telling users that the risk is "minimal."

"There is no public exploit, the details are private, and so the risk to users is minimal," Window Snyder, Mozilla's chief security officer, said in an entry to a company blog.

According to the security company that reported the vulnerability to Mozilla, the bug is present in the Windows, Mac OS X and Linux versions of Firefox. Later Thursday, Snyder confirmed that the Windows and Mac versions of Firefox contained the vulnerability, but said her team had not yet verified that the Linux version also had the flaw.

Snyder was responding to news yesterday that 3Com Corp.'s TippingPoint, a security vendor that runs the Zero Day Initiative bug bounty program, had purchased a critical Firefox 3.0 vulnerability from an unnamed researcher and then forwarded information on the bug to Mozilla.

As per its policy, TippingPoint said it would not release details of the bug until Mozilla has crafted a patch. Yesterday, however, it noted that the vulnerability would let hackers execute remote code -- making the bug a critical flaw -- and that it would require some action by the potential victim, such as clicking on a link in an e-mail message or visiting a malicious or compromised site.

Today, Terri Forslof, TippingPoint's manager of security response, expanded somewhat on the vulnerability's range. "It's not operating system specific," she said. "It's browser specific, only on Firefox, but on Windows, Mac and Linux."

Snyder confirmed that she had received word from TippingPoint -- Forslof said she e-mailed Snyder directly with a heads-up -- and that the Mozilla team was looking into the problem. "To protect our users, the details of the issue will remain closed until a patch is made available," she said.

The fix will come in the next security updates for Firefox 2.0 and Firefox 3.0, Snyder said. She declined to be specific about a timetable.

Yesterday, TippingPoint sounded confident that Mozilla would quickly fix the flaw. "Working with Mozilla on past security issues, we've found them to have a good track record and expect a reasonable turnaround on this issue as well," TippingPoint noted in a blog posting of its own.

Mozilla didn't provide additional information or offer recommendations for users, but Forslof was willing to do so. "This is in the same line as lots of other browser vulnerabilities," she said, "so the advice is in the same line, too. Don't click on links in e-mail, make sure the operating system is up to date, and don't visit unsafe sites."

Forslof added that the researcher, who has chosen to remain anonymous, is someone TippingPoint has worked with before. "He's a regular contributor to our program," she said.

She wouldn't disclose more than that, but did say it wasn't unusual for researchers to suddenly reveal a vulnerability that they'd discovered some time before. "I can think of several examples," Forslof said. "It's highly likely that he [found the bug] in their last version [of Firefox] and was just waiting for them to release 3.0 to see if they'd fixed it there."

According to both TippingPoint and Mozilla, the vulnerability is in the older Firefox 2.0 series as well as the brand-new Firefox 3.0, which launched Tuesday.


Thursday, June 19, 2008

New VIA VX800 Series Chipsets to Extend VIA Leadership in Ultra Mobile Market

Taipei, Taiwan, 1 April 2008 - VIA Technologies, Inc, a leading innovator of power efficient x86 processor platforms, today announced the new VIA VX800 Series of digital media IGP chipsets featuring the latest video, graphics and connectivity performance in a single chip measuring just 33 x 33mm.

The VIA VX800 Series comprises two primary digital media IGP chipsets, the VIA VX800 for ultra thin and light notebooks, mini PCs and embedded devices, and the ultra low voltage VIA VX800U for the fast-expanding ultra mobile market, including the rapidly-emerging mini-note, UMPC and UMD markets.

Strategic to the continued success of the VIA Ultra Mobile Platform based on the VIA C7®-M ULV processor, the VIA VX800U looks set to further boost VIA's leadership in ultra mobile platforms, packing a host of features into an even more power efficient package with a maximum power draw of only 3.5 watts.

Bringing high quality graphics, video and memory performance to ultra compact x86 systems, the VIA VX800U series delivers full Microsoft® DirectX® 9 3D graphics, high definition video and audio playback, and support for up to 4GB of DDR2 system memory.

Fully Microsoft Windows Vista™ compliant, the VIA VX800 Series supports both current VIA C7, VIA C7-M and VIA Eden processors and also upcoming processors based on the VIA Isaiah Architecture, ensuring vendors can offer a wider range of performance and price points utilizing the same platform infrastructure.

"The explosive growth of the Mini-Note category and the emerging Ultra Mobile Device category has clearly demonstrated the increased importance on low power, high performance, and small footprint," and said Richard Brown, Vice President of Corporate Marketing, VIA Technologies, Inc. "The VIA VX800 Series goes a long way towards maintaining VIA's leadership in the ultra mobile and other key market segments, and allows our customers to bring products with enhanced features and performance to market faster."