Saturday, July 16, 2011

Linux: loopback address

I run a java application under Linux environment and it throw an exception.

"Server failed to start: java.rmi.RemoteException: Cannot start. localhost.localdomain is a loopback address"

The problem seems related to the host file (\etc\hosts) and its content is shown below:

127.0.0.1 localhost.localdomain localhost
::1 localhost






After the configuration, everything works fine.

Thursday, July 14, 2011

OleDbConnection: insert a parameter into a query

I want to create a OleDbConnection to a excel file and create a parameterized query. An example from msdn is shown below:

string queryString = "SELECT * FROM Table1 WHERE Field1 LIKE ?";
OleDbCommand command = new OleDbCommand(queryString, connection);
command.Parameters.Add("@p1", OleDbType.Char, 3).Value = "a";
OleDbDataReader reader = command.ExecuteReader();

For your reference:
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbparameter.aspx
http://blogs.msdn.com/b/wriju/archive/2008/01/24/ado-net-oledbcommand-parameterized-query-sequence-rule.aspx