San Nan

Greenhorn
+ Follow
since Jul 01, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by San Nan

Dear All,

I am having a store proc in backend (SQL Server) & instead of calling the store proc from java program ( through Callable) i want to make a function in java, which can be called without callable....

Please help me to provide solution by providing source code


Thanks


Nan
Dear All,

=====================================================
I have created a StackedBar chart using JFreeChart. it working fine. the code is :->
======================================================

import java.awt.Dimension;
import java.text.DecimalFormat;
import java.text.NumberFormat;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.TextAnchor;
import org.jfree.ui.RectangleInsets;
import org.jfree.ui.RefineryUtilities;
import org.jfree.chart.axis.*;
public class First2 extends ApplicationFrame
{
public First2(final String title) {

super(title);

final CategoryDataset dataset = createDataset();
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(chartPanel);

}


private CategoryDataset createDataset() {
// row keys...
final String series1 = "S1";
final String series2 = "S2";
final String series3 = "S3";

// column keys...
final String category1 = "January";
final String category2 = "February";
final String category3 = "March";

// create the dataset...
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

dataset.addValue(1.0, series1, category1);
dataset.addValue(4.0, series1, category2);
dataset.addValue(3.0, series1, category3);

// For Negative Value
// Put - (Minus) symbol before the value

dataset.addValue(5.0, series2, category1);
dataset.addValue(7.0, series2, category2);
dataset.addValue(6.0, series2, category3);

dataset.addValue(4.0, series3, category1);
dataset.addValue(3.0, series3, category2);
dataset.addValue(2.0, series3, category3);

return dataset;
}



private JFreeChart createChart(final CategoryDataset dataset)
{
// create the chart...
final JFreeChart chart = ChartFactory.createStackedBarChart3D
(
"Stacked Bar Chart", // chart title
"M o n t h s", // domain axis label
"Value in $", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);





org.jfree.chart.plot.CategoryPlot categoryplot = chart.getCategoryPlot();
categoryplot.setBackgroundPaint(java.awt.Color.lightGray);
categoryplot.setRangeGridlinePaint(java.awt.Color.white);
categoryplot.setRangeGridlinesVisible(true);
org.jfree.chart.renderer.category.BarRenderer barrenderer =
(org.jfree.chart.renderer.category.BarRenderer)categoryplot.getRenderer();


java.text.DecimalFormat decimalformat1 = new DecimalFormat("$##,###.00");
decimalformat1.setNegativePrefix("(");
decimalformat1.setNegativeSuffix(")");
barrenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1));

// displaying Value on Each Bar
barrenderer.setItemLabelsVisible(true);


return chart;

}

public static void main(final String[] args) {

final First2 demo = new First2("Stacked Bar Chart");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);


}
}

===============================================================

Now i want to display a Dollar Symbol at Vertical Bar For Displying the Values in Dollar..... Can ANyone Please Help me for the Same..


Thanks & Regards


San Nan
Dear All,

I have created a Chart with JFreeChart. The Code is as below. but i want to display the data with Dollar symbols.

please help me by telling that how can i display data in Chart with Dollar Symbols......


Code ::::::::->>>>>>>


import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;

public class PieChartExample extends JPanel
{
// Holds the data
private DefaultPieDataset dataset = new DefaultPieDataset();



// Create a set of charts
private JFreeChart chart1;
// Create a set of panels that can show charts
private ChartPanel panel1;
public PieChartExample()
{
// Initialize the dataset
dataset.setValue( "San", new Double( 16.0 ) );
dataset.setValue( "San1", new Double( 67.0 ) );
dataset.setValue( "San2", new Double( 18.0 ) );
dataset.setValue( "San3", new Double( 40.0 ) );

// Create the charts
chart1 = ChartFactory.createPieChart3D(
" Performance Chart ", // The chart title
dataset, // The dataset for the chart
true, // Is a legend required?
true, // Use tooltips
false // Configure chart to generate URLs?
);


// Create this panel
this.setLayout( new GridLayout( 2, 2 ) );
this.panel1 = new ChartPanel( chart1 );
this.add( panel1 );
}

public static void main( String[] args )
{
JFrame frame = new JFrame( "San Nan" );
PieChartExample chart = new PieChartExample();
frame.getContentPane().add( chart, BorderLayout.CENTER );
frame.setSize( 640, 480 );
frame.setVisible( true );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}



Thanks & Regards

San Nan
Dear All,

I have created a Chart with JFreeChart. The Code is as below. but i want to display the data with Dollar symbols.

please help me by telling that how can i display data in Chart with Dollar Symbols......


Code ::::::::->>>>>>>


import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;

public class PieChartExample extends JPanel
{
// Holds the data
private DefaultPieDataset dataset = new DefaultPieDataset();



// Create a set of charts
private JFreeChart chart1;
// Create a set of panels that can show charts
private ChartPanel panel1;
public PieChartExample()
{
// Initialize the dataset
dataset.setValue( "San", new Double( 16.0 ) );
dataset.setValue( "San1", new Double( 67.0 ) );
dataset.setValue( "San2", new Double( 18.0 ) );
dataset.setValue( "San3", new Double( 40.0 ) );

// Create the charts
chart1 = ChartFactory.createPieChart3D(
" Performance Chart ", // The chart title
dataset, // The dataset for the chart
true, // Is a legend required?
true, // Use tooltips
false // Configure chart to generate URLs?
);


// Create this panel
this.setLayout( new GridLayout( 2, 2 ) );
this.panel1 = new ChartPanel( chart1 );
this.add( panel1 );
}

public static void main( String[] args )
{
JFrame frame = new JFrame( "San Nan" );
PieChartExample chart = new PieChartExample();
frame.getContentPane().add( chart, BorderLayout.CENTER );
frame.setSize( 640, 480 );
frame.setVisible( true );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}



Thanks & Regards

San Nan
Dear All,

I have created a Chart with JFreeChart. The Code is as below. but i want to display the data with Dollar symbols.

please help me by telling that how can i display data in Chart with Dollar Symbols......


Code ::::::::->>>>>>>


import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;

public class PieChartExample extends JPanel
{
// Holds the data
private DefaultPieDataset dataset = new DefaultPieDataset();



// Create a set of charts
private JFreeChart chart1;
// Create a set of panels that can show charts
private ChartPanel panel1;
public PieChartExample()
{
// Initialize the dataset
dataset.setValue( "San", new Double( 16.0 ) );
dataset.setValue( "San1", new Double( 67.0 ) );
dataset.setValue( "San2", new Double( 18.0 ) );
dataset.setValue( "San3", new Double( 40.0 ) );

// Create the charts
chart1 = ChartFactory.createPieChart3D(
" Performance Chart ", // The chart title
dataset, // The dataset for the chart
true, // Is a legend required?
true, // Use tooltips
false // Configure chart to generate URLs?
);


// Create this panel
this.setLayout( new GridLayout( 2, 2 ) );
this.panel1 = new ChartPanel( chart1 );
this.add( panel1 );
}

public static void main( String[] args )
{
JFrame frame = new JFrame( "San Nan" );
PieChartExample chart = new PieChartExample();
frame.getContentPane().add( chart, BorderLayout.CENTER );
frame.setSize( 640, 480 );
frame.setVisible( true );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}



Thanks & Regards

San Nan
14 years ago
Dear All,

I am Making a small application for Database Communication for spring with MySql.

The Source is :


1)
import javax.sql.*;

public interface datacon

{

public DataSource dbcon();

}

2)
import org.springframework.jdbc.core.*;

import org.springframework.jdbc.datasource.*;

import org.springframework.jdbc.object.*;

import org.springframework.jdbc.support.*;

import javax.sql.*;

public class dataconimpl implements datacon

{

private DataSource dataSource;

public void setDataSource(DataSource ds)

{

dataSource = ds;

}

public DataSource dbcon()

{

return dataSource;

}

}

3)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">;

<beans>

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</property>
<property name="url">
<value>jdbc dbc:test</value>
</property>
<!--
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>sql</value>
</property>
-->
</bean>

<bean id="datacon" class="dataconimpl">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>

</beans>

4)
import java.io.*;

import javax.sql.*;

import java.sql.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

import org.springframework.beans.factory.*;

import org.springframework.beans.factory.xml.*;

import org.springframework.core.io.*;

import org.springframework.jdbc.core.*;

import org.springframework.jdbc.datasource.*;

import org.springframework.jdbc.object.*;

import org.springframework.jdbc.support.*;

public class springservlet extends HttpServlet

{

public void doPost(HttpServletRequest req,HttpServletResponse resp)

throws ServletException,IOException

{
System.out.println("Sanju1");
resp.setContentType("text/html");

PrintWriter out = resp.getWriter();

System.out.println("Sanju2");
String a = req.getParameter("text1");

String b = req.getParameter("text2");
System.out.println("Sanju3");
String c = req.getParameter("combo1");

String d = req.getParameter("combo2");

try

{

System.out.println("Wait...");

Resource res = new ClassPathResource("datacon.xml");

BeanFactory factory = new XmlBeanFactory(res);

datacon bean1 = (datacon)factory.getBean("datacon");
System.out.println("Sanju4");

DataSource ds=bean1.dbcon();
System.out.println("Sanju5");

if(d.equals("add"))

{
System.out.println("Sanju6");

JdbcTemplate jt = new JdbcTemplate(ds);
System.out.println("Sanju7");

jt.execute("insert into table1 values('"+a+"','"+b+"') ");
System.out.println("Sanju8");

out.println("Record Added");
System.out.println("Sanju9");

}

if(d.equals("delete"))

{

JdbcTemplate jt = new JdbcTemplate(ds);

jt.execute("delete from table1 where name='"+a+"' ");

out.println("Record Deleted");

}

if(d.equals("find"))

{

List list1;

JdbcTemplate jt = new JdbcTemplate(ds);

list1=jt.queryForList("select * from table1 where name='"+a+"'");

Iterator i=list1.iterator();

while(i.hasNext())

{

Object ob = i.next();

out.println(ob.toString());

}

}

if(d.equals("update"))

{

if(c.equals("name"))

{

JdbcTemplate jt = new JdbcTemplate(ds);

jt.execute("update table1 set table1.place='"+b+"'where table1.name='"+a+"' ");

}

if(c.equals("place"))

{

JdbcTemplate jt = new JdbcTemplate(ds);

jt.execute("update table1 set table1.name='"+a+"'where table1.place='"+b+"' ");

}

out.println("Record Updated");

}

}

catch(Exception e1)

{System.out.println("Sorry "+e1);}

}

}


5)
<html>
<body bgcolor="pink">
<form method=post action="http://localhost:8080/Sanjay/springservlet">;
Name : <input type=text name="text1"> <br><br>
Place: <input type=text name="text2"> <br><br>
Criterion :
<select name="combo1" size=1>
<option value="name">Name
<option value="place">Place
</select> <br><br>

<select name="combo2" size=1>
<option value="add">Add
<option value="delete">Remove
<option value="find">Find
<option value="update">Update
</select> <br><br>
<input type=submit>
</form>
</body>
</html>

================================================================
I have also created a table in test database ( table1)

I have created a DSN ( without password & checked ( Tested) ( tried with User DSN & also with System DSN)
===============================================================


I am Getting the Following Error :

Error while getting database metadata
org.springframework.jdbc.support.MetaDataAccessException: Error while getting connection; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3028)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:156)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:144)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:132)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:165)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:144)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:120)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:93)
at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:209)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:115)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:96)
at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:76)
at org.springframework.jdbc.support.JdbcAccessor.afterPropertiesSet(JdbcAccessor.java:93)
at org.springframework.jdbc.core.JdbcTemplate.<init>(JdbcTemplate.java:131)
at springservlet.doPost(springservlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Spring is framework with IOC & AOP. Hibernate can be used to connect with daabase with ORM .
I found a good source code At :

http://www.javaworld.com/javaworld/jw-02-2005/jw-0214-springejb_p.html


but still wants to know how spring deals with JNDI Lookup


San Nan
Dear All,

Please help me for making a stateless or stateful session bean by using Spring.

Please provide me steps for the same


Thanks & regards


San Nan
Dear All,

I am New to Spring & wants an application source for communicating with hibernate.

Please provide me the help for how to communicate Spring+Hibernate+mySql.


Thanks & Regards

San Nan
Dear All,


Can Any one please send me the source code for simple stateless bean code for Spring.

( e.g. How to make & execute a Stateless Session Bean in Spring Framework)


Thanks !!!
Thanks !!! for the Solution
Thanks !!! for the Solution & advice
Dear All,


Can Any one Tell me the Practical Difference Between AOP & IOC.


Thanks