Search This Blog

Saturday, September 20, 2008

Installing JDK 1.5.0_15 on Damn Small Linux - Not

This actually is a no brainer, any one can do it, but still i thought i would right it down, may be a reference for me, to remember what i did. It was pretty much same as how you do it in rest of the linux distros, no exceptions.

First i went to sun's website and downloaded the .bin installation file. (not the rpm one). since i wanted to install in a place from where i can access it for all users. i became root. then i copied the .bin file to /usr/local, then enabled executable permissions to it and then executed the file. that is it. it got installed into /usr/local/jdk1.5.0_15.. I will list the exact steps which i had done.

$su
$cp /home/dsl/jdk-1_5_0_15-linux-i586.bin /usr/local/
$cd /usr/local
$chmod a+x jdk-1_5_0_15-linux-i586.bin
$./jdk-1_5_0_15-linux-i586.bin

after this, i logged in to another terminal and edited the .bashrc file to set the java_home and path variables, so as to access the commands directly in command prompt.

in terminal enter
$cd
$vi .bashrc
(or)
$vi .bash_profile

then at the end of the file add the following lines.

export JAVA_HOME=/usr/local/jdk1.5.0_15
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/lib

save the file and exit, and do a machine restart(it should work if you open another terminal and check, but all failed and only a reboot worked in my case).....

Thursday, September 18, 2008

Damn Small Linux on VmWare

I have known DSL for a long time (say since mid 2005 ..).  But i had never thought of it as anything more than a os on a cd to be used when my system hiccups.

I am in delhi, and am void of access to any system sparing my office pc here.  and that to i can't install anything on it.  So now me being far away from linux was sort of taking a toll on me.  so i decided to install linux on vmware as it was already there in my machine.

Initially i had tried to install it, though everything went smoothly, but it did not work or to be precise it did not boot into the newly installed system.  Then on further digging around i found it did not handle scsi disks so i had to set it to IDE.  I forgot where i had found the info, you will get it with a simple google.  i am too lazy to go around.  but it was inthe dsl forums.  That much i remember.

i will say what i had done.

First i had created a virtual IDE disk for 3 GB.
then after booting into the ISO, i went into terminal and became root.
now i ran cfdisk, and created two partitions 1 gb swap and rest as ext3 bootable.
then i started the installation with the command dsl-hdinstall.  and went ahead with the default at everyplace.

after 10 mins it was there.  i was asked to reboot and it went right into the hd boot.  now things were working fine.  Now i am planning to install jdk (which should not be a problem), mysql and then dimension, and take it for a test run...

Monday, September 08, 2008

A Hard Decision

i don't know weather i am doing it correct by writing this post. But, as the saying goes, when in doubt....

It is not everyday that some one who is up the ladder at the near top of the organization would call you for a chat.

It is not everyday that, that one person at the top of the organization, would offer a dream chance to join his elite team.

And it is not everyday that you would reject the offer and live the rest of the life as though nothing had happened.

There were not so many reasons why i said no to his offer... only a few,
  • His thinking of only his solution is correct.
  • Being asked to stay in Delhi.
  • The rest of office's attitude.
If he can work around the first 2 points, i can work something out of the 3 point. But i can't do anything. and the verdict had been spilled out of my mouth.

As i have heard, it was difficult to say No. But somehow, i did......

Transfering data from one database to another

Hmm, Most of what i am going to say in this here, will be childish, but still....

DimensioN is built on top of JBOSS. It has some inbuilt functionality to export data from one database to another, with some rules associated with it. and that is great, But what it lacks is you cannot pick and choose which records you want to transfer. That was a problem.

There is a way to atttain the solution for this problem in DimensioN, but the application architecture which we had decided upon did not permit, or to be correct will make it too complex, for the future DimensioN developer to understand and tackle any problems if they should arise. this would invove the logic as follows,

rModify --> DbImport --> rModify....

And as you can see rModify is a bit of a highlevel feature, and many still dread to use it. so the only thing which i could think off was using some thing else which is out of DimensioN but still could be used with it, like Ant target or something.

My first choice was to use Ant target, coz i have done database manipulation with it for an other project, previously. As i can use it as a template and proceed off, and that would save time too. But, i ran into trouble with it, First i had to make javascript to work from inside Ant and then after i had succeded, when i had tried to do the database manipulation, it was creating a exception saying Illegal Access Exception, some AntClassLoader came in and some bullshit which i was not able to understand. and i had waited for 3 days for OS support, but when i came to know that help might not arrive on time, i wanted to put in something to get things going till the support arrived.

Another two days and that jsp expert had not finished the job yet, and they were pressing me for an answer, as though i was a part of that project. ( i had moved to another one even b4 the problem started). Well then, i had to sit back and write the code again for the jsp. (i hate to code. but this was as usual Reverse Engineering, as i would put it,coz i know the basics to do anything, i just did not have the time to proceed to write things from scratch.) I had set a deadline of 4 hours for me to finish. and i sat down to write the code. it took me 3 hours and a half to do it. and it was pretty much good, without any problems, and is working fine.

I know there are still 2 potential pit falls..... (1) I haven't used a try catch block, so if any exceptions are thrown the page will be a error. which i will have to correct in the future... (2) I haven't used parameterized prepare statement, so if the data is going to have any problems like a single quote, or anything that would hamper a insert statement on syntax, yet again the page will break with an error.

So with these details, i give you the code. it might be helpful to someone.
-----------------------------------------------------------------------

<%@ page import="java.sql.*" %>
<%@ page language="java" session="true" %>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.springframework.jdbc.core .*"%>
<%
////////////////////////////////////////////////////////////////////////////////////////////////////////
// ExporttoErp.jsp //
// //
// File Created on September 5th 2008 at 1807 hrs. //
// Last Modified on September 5th 2008 at 2030 hrs. //
// Modified By Anbarasan //
// //
// This page exports data from dimension database to navision database. //
// We get the record identifier from the url. //
// Then we proceed to retrive data from dimension and then push it into navision. //
/////////////////////////////////////////////////////////////////////////////////////////////////////////
%>
<html>
<head>
<title>
DbExport utility to export Single Record of choice to ERP.
</title>
</head>
<body>
<%
String id=request.getParameter("docid");
////////////////////////////////////////////////////////////////////////////////////////////////
// Enable the following line to see the primary key id that is being passed. //
///////////////////////////////////////////////////////////////////////////////////////////////
// out.println(id);
////////////////////////////////////////////////////////
// Connection to Dimension's Database //
////////////////////////////////////////////////////////
DataSource dimds = (DataSource)com.orangescape.hce.server.services.CsServiceLocator.getInstance().fetchObject("java:dimension");
Connection dimconn = null;
dimconn = dimds.getConnection();
//////////////////////////////////////////////////
// Connection to Navision's Database //
//////////////////////////////////////////////////
DataSource navds = (DataSource)com.orangescape.hce.server.services.CsServiceLocator.getInstance().fetchObject("java:erp");
Connection navconn = null;
navconn = navds.getConnection();

String dimparentqry="select [Amount],[Bill-to Customer No_],[Chain Name],[Created On Date],[Customer_PO_date],[External Document No_],[Location Code],[Octroi Amount],[Octroi Applicable],[Order Type],[Order Value],[Project Date],[project No_ updation],[Promised Delivery Date],[Req_ delivery Date],[Sales Cordinator Code],[Sales Cordinator Name],[Salesperson Code],[Sell-to Customer No_],[Shortcut Dimension 1 Code],[Shortcut Dimension 12 Code],[DocID] from [xxxxxxxx Pvt_ Ltd_$temp sales header] where docid = '"+id+"'";
String dimchildqry="select [Approx_ Cost],[Line No_],[No_],[puchase order no_line],[Quantity],[SODetailsId],[Unit of Measure],[Unit Price],[Variant Code] from [xxxxxxxxx Pvt_ Ltd_$temp sales line] where SODetailsId='"+id+"'";

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Enable the following line to see what the data retrival query from dimension database is..... //
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// out.println("<b>ParentQuery</b><br>"+dimparentqry);
// out.println("<br><br><br>");
// out.println("<b>ChildQuery</b><br>"+dimchildqry);
// out.println("<br><br><br>");
//////////////////////////////////////////////////////////////////////////////////////////////////////////
Statement dimst=dimconn.createStatement();
ResultSet dimrs=dimst.executeQuery(dimparentqry);

while(dimrs.next()){
String navparentqry="insert into [xxxxxxxx Pvt_ Ltd_$temp sales header] ([Amount],[Bill-to Customer No_],[Chain Name],[Created On Date],[Customer_PO_date],[External Document No_],[Location Code],[Octroi Amount],[Octroi Applicable],[Order Type],[Order Value],[Project Date],[Project No_],[Promised Delivery Date],[Req_ delivery Date],[Sales Cordinator Code],[Sales Cordinator Name],[Salesperson Code],[Sell-to Customer No_],[Shortcut Dimension 1 Code],[Shortcut Dimension 12 Code],[SO Document ID],[SO No_ Of SCM]) values (";
navparentqry = navparentqry + dimrs.getString("Amount") + ", ";
navparentqry = navparentqry + "'" + dimrs.getString("Bill-to Customer No_") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Chain Name") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Created On Date") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Customer_PO_date") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("External Document No_") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Location Code") + "', ";
navparentqry = navparentqry + dimrs.getString("Octroi Amount") + ", ";
navparentqry = navparentqry + dimrs.getString("Octroi Applicable") + ", ";
navparentqry = navparentqry + "'" + dimrs.getString("Order Type") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Order Value") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Project Date") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("project No_ updation") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Promised Delivery Date") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Req_ delivery Date") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Sales Cordinator Code") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Sales Cordinator Name") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Salesperson Code") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Sell-to Customer No_") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Shortcut Dimension 1 Code") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("Shortcut Dimension 12 Code") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("DocID") + "', ";
navparentqry = navparentqry + "'" + dimrs.getString("DocID") + "')";

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Enable the following line to see what the data posting query to erpdatabase is..... //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// out.println(navparentqry);

PreparedStatement navst=navconn.prepareStatement(navparentqry);
navst.executeUpdate();

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// i don't know what is wrong with this method, but it throws com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set. //
// ResultSet navrs=navst.executeQuery(navparentqry); //
// navst.executeQuery(navparentqry); //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

dimrs=null;
dimst=dimconn.createStatement();
dimrs=dimst.executeQuery(dimchildqry);

while(dimrs.next()){
String navchildqry ="insert into [xxxxxxxx Pvt_ Ltd_$temp sales line] ([Approx_ Cost],[Line No_],[No_],[po no update],[Quantity],[SO No_ Of SCM],[Unit of Measure],[Unit Price],[Variant Code]) values (";
navchildqry = navchildqry + dimrs.getString("Approx_ Cost") +", ";
navchildqry = navchildqry + dimrs.getString("Line No_") +", ";
navchildqry = navchildqry + "'" + dimrs.getString("No_") +"', ";
navchildqry = navchildqry + "'" + dimrs.getString("puchase order no_line") +"', ";
navchildqry = navchildqry + dimrs.getString("Quantity") +", ";
navchildqry = navchildqry + "'" + dimrs.getString("SODetailsId") +"', ";
navchildqry = navchildqry + "'" + dimrs.getString("Unit of Measure") +"', ";
navchildqry = navchildqry + dimrs.getString("Unit Price") +", ";
navchildqry = navchildqry + "'" + dimrs.getString("Variant Code") +"') ";

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Enable the following line to see what the data posting query to erp database is..... //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// out.println(navchildqry);

PreparedStatement navst=navconn.prepareStatement(navchildqry);
navst.executeUpdate();
}

navconn.close();
dimconn.close();

//////////////////////////////////////////////////////////////////////////////////////////
// A display message to indicate the end of the posting of data process..... //
//////////////////////////////////////////////////////////////////////////////////////////
out.println("<center><h1>Data Transferred to erp with SO Number : "+id+"</h1></center>");
%>
</body>
</html>