Thursday, December 24, 2009

DATASOURCE CONFIGURATION IN TOMCAT, zeroDateTimeBehavior=convertToNull

A . Please add the following jars in the lib of tomcat application server.

1.mysql-connector-java-3.1.12-bin.jar
2.tomcat-jdbc.jar
3.tomcat-juli.jar

B .Change the server.xml , add connection pooling information


/Context path="/*******" docBase="*******" debug="99" reloadable="true" /
/Resource name="********"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
testWhileIdle="true"
testOnBorrow="true"
testOnReturn="false"
validationQuery="SELECT 1 FROM *****"
validationInterval="300"
timeBetweenEvictionRunsMillis="30000"
maxActive="300"
minIdle="10"
maxWait="1000"
initialSize="30"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"
minEvictableIdleTimeMillis="300"
jmxEnabled="true"
username="*******"
password="*******"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/********?autoReconnect=true&zeroDateTimeBehavior=convertToNull"/

Tally ERP 9 Http XML communication

Hello while i was integrating my java/j2ee application with tally i taught of sharing my information with many developers who may get help in integrating there applications with Tally(which is widely used for accounting in India)

----------------------------CODE--------------------------------------------------------
package com.XXXX.hmis.utils;
/**
* KUMAR GAURAV SRIVASTAVA
*/


/**
*THIS IS A SAMPLE TO CREATE VOUCHER IN TALLY.ERP 9
*FOR TESTING SAVE IT AS test.xml, and CHANGE THE Url & xmlFile VALUES
*
*
*


*/




import java.io.*;
import java.net.*;

public class SOAPClient{
public static void main(String[] args) throws Exception {

String Url = "http://192.168.10.44:9999/";
String xmlFile = "/home/gaurav/Desktop/test.xml";

String SOAPAction = "";

// Create the connection where we're going to send the file.
URL url = new URL(Url);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;


FileInputStream fin = new FileInputStream(xmlFile2Send);

ByteArrayOutputStream bout = new ByteArrayOutputStream();

// Copy the SOAP file to the open connection.
copy(fin,bout);
fin.close();

byte[] b = bout.toByteArray();

// Set the appropriate HTTP parameters.
httpConn.setRequestProperty( "Content-Length",
String.valueOf( b.length ) );
httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
httpConn.setRequestProperty("SOAPAction",SOAPAction);
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);

// Everything's set up; send the XML that was read in to b.
OutputStream out = httpConn.getOutputStream();
out.write( b );
out.close();

// Read the response and write it to standard out.

InputStreamReader isr =
new InputStreamReader(httpConn.getInputStream());
BufferedReader in = new BufferedReader(isr);

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}

public static void copy(InputStream in, OutputStream out)
throws IOException {

// do not allow other threads to read from the
// input or write to the output while copying is
// taking place

synchronized (in) {
synchronized (out) {

byte[] buffer = new byte[256];
while (true) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) break;
out.write(buffer, 0, bytesRead);
}
}
}
}
}