LIVE IT

Lets make IT better by sharing the solutions

Wednesday, April 15, 2009

Error 1033:Incorrect file information dbname.tablename.frm

Following is the outcome of 5 Hours non stop trouble shooting.
This is Mysql Error which comes due to incompetible size of datafile(ibdata1) and ib_logfile0,..
Incompatible means it is not as mentioned in my.cnf file of mysql(which locates in /etc/mysql/ when you install default in ubuntu). This incompatibility makes innodb engine disabled so all the tables created with innodb db engine will stop working.To verify this check the have_innodb variable.
Above i explained the reason of the error now i will explain the solution for this:

Step 1: Backup your existing my.cnf(/etc/mysql/my.cnf).
Step 2: Try finding the sample my.cnf in your system these are mostly present in example directory of mysql. you can choose any .cnf file preferabbly my-medium.cnf.
Step 3: copy this to the loction where my.cnf was present and rename this to my.cnf
Step 4: go to /var/lib/mysql folder and check the size of ibdata1 file and open my.cnf for editing.
Step 4: first uncomment all the innodb related variables in the file then increase the size of log files and poolsize.Carefully change the size of innodb_data_file_path variable
the size of existing datafile for me it is ibdata1 should match exactly.For example, my datafile ibdata1 is of 35M so for this innodb_data_file_path will be as shown below.
# Uncomment the following if you are using InnoDB tables
#innodb
innodb_data_home_dir = /var/lib/mysql/
innodb_data_file_path = ibdata1:34M;ibdata2:500M:autoextend
innodb_log_group_home_dir = /var/lib/mysql/
innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 100M
innodb_additional_mem_pool_size = 80M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 25M
innodb_log_buffer_size = 100M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

Step 5: Save the settings and restart the Mysql.

---PRamod

Thursday, January 22, 2009

achieving multilingual support in non struts application

I use ZKas front end framework. In our application we need to have internationalization which i had already done in struts by overriding the methods of controller servlet.
But Here no such methods when we use JSP's or ZK pages i.e., ZUL. Even when i tried to get the content of textbox on the other page it shows junk characters.While saving in database it saves as set of ??? .
There are few mandate to achieve multilingual support to your java applications.
1.) The Request should be able to sent multilingual data i.e., in UTF-8 format.
2.)The view part such as JSP should be able to show the UTF-8 characters.
3)The database should suport UTF-8 format.

Here is the way to do this:
I have
Database: MYSQL 5.0
Server: Tomcat 6.0
JDK: 1.6
For achieving sep 1:
Add URIEncoding="UTF-8" attribute in node so that it look like

port="8081"
protocol="HTTP/1.1"
redirectPort="8443"
URIEncoding="UTF-8" />

For achieving sep 2:
set page encoding as UTF-8

or for JSP's
it is:<%@page contentType="text/html" pageEncoding="UTF-8"%>
For achieving sep 3:
Set default-character-set to utf8 in MySQL\MySQL Server 5.0\my.ini file
default-character-set=utf8


Hope this might help

Monday, July 28, 2008

SQL Server Date Problem

In java if you are using SQL Server you might come across an error like:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
The problem is that there is no Date datatype for SQL Server rather we have DATETIME whose JDBC Equivalent is java.sql.Timestamp.
So, to use setDate method we need to pass java.sql.Timestamp as date.
Note : For mySQL and many other databases we are fine with Date

Friday, July 18, 2008

Multilanguage Support to Struts

As we have heard so many time that sturs i a frame work which provide multilingual support very easly.Its true for those languages which supports ascii characters.For Arabic like languages its not that easy. There is one standard characterset format that is UTF-8,which supports many languages including Arabics also. So while developing multilanguage application one has to concentrate on characterset which s UTF-8.Talking About java which is UTF-16 by default so we will not get the proper result simply. Following are the steps involved in making it UTF-8 centric.
The .properties file for that language should be converted into UTF-8 format using
native2ascii utility of jdk.
the spl character written on the page will display like \uXXX\uYYY.
Now make your jsp page able to present in UTF-8 format by setting charset as UTF-8.
Now set the request encoding to UTF-8.
If you are using database make sure charecterset variable of you db is set to UTF-8.
Also the database shold be created after setting characterset.
Its done now.
For detail code contact me on mail....mailid:mydesires100@gmail.com

Monday, July 14, 2008

Trapping Window Close for Internet Explorer

Today i come across a scenario where , if the close button of internet explorer is clicked and i need to call a logout action to have safe signout.So i scroll through internet all the way , I came to know about so many ways but non of them worked for me . But i got the clue how to proceed , I proceed as
Place the follwing java script code on your page between script tag

function whileClosing() {
if((window.event.clientX>1000)(window.event.clientY<-100)) {
document.forms[0].action="<%=sLinkPrefix%>/logoutAction.do";
document.forms[0].submit(); }
else { alert("Refresh"); }
}
window.onunload=whileClosing;
Here clientX,clientY is the location where the click is done so better you alert these locations and check what are the coordinated of close button,
Note : This might be different Coordinated for other Resolutions.Please check to trap the resolutions of your system and let me know if you are done.

Thursday, July 10, 2008

Java Collection 1

Collections in java has been provided to have the better approach for managing your data and and their representation. By data we mean the contentent and by representation we mean how you cordinate your data to use it efficiently.
Now the Question arises why use collection , collection is kind of low level implementation so to let the programmers concentrate on their main logics rather than putting them busy for low level implementations . Also, these are the standards libs so they are well tested and efficient to use in your applications.