Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

rameshmca rk

Greenhorn
+ Follow
since Jan 27, 2007
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 rameshmca rk

Hi,
How can I use crystal reports from Java applications?

Thanks and regards,
Ramesh RK
14 years ago
Hi,
This is my complete program interfaces bean class and a main method client


HelloBean.java -The bean implementation class

package advice;

import javax.ejb.*;

public class HelloBean implements SessionBean, HelloLocalBusiness {
private SessionContext context;

public void setSessionContext(SessionContext aContext) {
context = aContext;
}

public void ejbActivate() {

}

public void ejbPassivate() {

}

public void ejbRemove() {

}
public void ejbCreate() {
// TODO implement ejbCreate if necessary, acquire resources
// This method has access to the JNDI context so resource aquisition
// spanning all methods can be performed here such as home interfaces
// and data sources.
}

public String sayHello() {
return("Hello");
}

}

HelloLocal.java-Component interface


package advice;

import javax.ejb.EJBLocalObject;


/**
* This is the local interface for Hello enterprise bean.
*/
public interface HelloLocal extends EJBLocalObject, HelloLocalBusiness {
}


HelloLocalHome.java


package advice;

import javax.ejb.CreateException;
import javax.ejb.EJBLocalHome;


/**
* This is the local-home interface for Hello enterprise bean.
*/
public interface HelloLocalHome extends EJBLocalHome
{
HelloLocal create() throws CreateException;
}


HelloLocalBusiness.java


package advice;


/**
* This is the business interface for Hello enterprise bean.
*/
public interface HelloLocalBusiness {
String sayHello();
}

HelloClient.java

package client;
import advice.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import javax.ejb.*;
import java.util.*;

public class HelloClient {

/** Creates a new instance of HelloClient */
public HelloClient() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try
{
Properties prop=System.getProperties();
prop.put("INITIAL_CONTEXT_FACTORY","java.naming.factory.initial");
Context ctx=new InitialContext(prop);
Object o=ctx.lookup("ejb.Hello");
HelloLocalHome helloHome=(HelloLocalHome)o;
HelloLocal hello=helloHome.create();
System.out.println(hello.sayHello());
}
catch(Exception ex)
{
ex.printStackTrace();
}

}

}

output for this client program is follows

javax.naming.NoInitialContextException:
Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:

java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at client.HelloClient.main(HelloClient.java:37)

I have compiled this program numerous times but got the same result.I used netbeans5.0 IDE and Sun Java Apps Server 8.2. Help me to give the detailed code with descriptions of settings for env entries and URL Specifications to access the local host.

Thanks and regards,
Ramesh RK
Could you send me the complete code to identify the cause of the error.I think you should set the classpath for the class specified in the exception.
Hi,
I want to know details of setting column headings with data on JTable.I have given the program.Could you correct it to achieve the result?

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;

public class Queresult extends JFrame
{
public Queresult()
{
//System.out.println("Welcome");

super(" Testing JTable ");
//Frame fm=new Frame();
JMenuBar bar=new JMenuBar();
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

JMenu m1=new JMenu("Master");
JMenu exit=new JMenu("Exit");

JMenuItem m1f1=new JMenuItem("JTable Form");
JMenuItem f6=new JMenuItem("Close");

m1.add(m1f1);
exit.add(f6);

bar.add(m1);
bar.add(exit);

setJMenuBar(bar);

f6.setForeground(Color.red);

setSize(800,570);
show();

addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}});

m1f1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Frame fm1=new Frame();form1 d=new form1(fm1);}});

f6.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);}});

}
catch(Exception e)
{
e.printStackTrace();
}

}
public static void main(String args[])
{
new Queresult();
}
}

class form1 extends Dialog
{
JTable jt;
ResultSet rset=null;
Connection con=null;
Statement stmt=null;

form1(Frame fm1)
{
super(fm1);
setLayout(null);
setVisible(true);
Color c1=new Color(0,125,125);
setBackground(c1);
setSize(800,570);
setLocation(0,0);

final String[] colhead={"nou","uname"};
final Object[][] data={{"aaa","1234"},{"bbb","555"}};

jt=new JTable(data, colhead);
jt.setSize(200,100);
jt.setLocation(102,105);

add(jt);

}

}
14 years ago
Hi priya,
You would set the classpath to the client jar returned from deployment
like set classpath=.;myclient.jar; if the client jar returned is "myclient.jar".So the client program get the stub classes from that jar.
I hope you would get the solution.

Ramesh RK
Hi,
I want to know details about setting names for objects using JNDI naming servcices and also the details of making lookup for those names by using main methos class.I got error while I try this using main method class?Is not possible to make a lookup inside main method class?I require the settings and complete look up program.

Thanks and regards,
Ramesh RK
thank you jaikiran,
you have said a bean can call itself.How can we look up localhome using JNDI name inside the main method client?Could you give me the complete code for look up with property setting?

Thanks and regards,
Ramesh RK
Hi,
Is it possible to create EJB and make look up in the same machine?How?Could you give me the sample code?

Thanks and regards,
Ramesh RK
Hi,
How can we create report in Java?Is there any third party tool available like 'Crystal Report viewer'?If so How can we integrate crystal report with java?

Thanks and regards,
Ramesh RK
14 years ago
Hi,
I have generated a EJB Program that is session bean giving advice to the main() method class client when is requested.I got the exception "NoInitialContextException". In the client program I have specified the JNDI name "hellobean".How can I set this name in Sun Java Application Server 8.2? .There is no specification for JNDI name in the server's deploy tool. Where can I set the JNDI name?I have been trying myself for months without getting results.My bean uses local interfaces.Is it possible to specify JNDI name for local client?. help me to resolve this problem.Also I tried headfirst EJB.

Thanks and regards,
Ramesh RK
Hi,
I have sent my program as follows.So I trust you that I will be satisfied.


//Example program for testing insert statement for ERP

import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class InsertGUI1 extends JFrame implements ActionListener
{
JLabel jl1;
JLabel jl2;
JLabel jl3;
JLabel jl4;
JLabel jl5;
JTextField jtf1;
JTextField jtf2;
JTextField jtf3;
JTextField jtf4;
JTextField jtf5;
JLabel result;
JButton jb;
public InsertGUI1(String title)
{
super(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentpane=getContentPane();
contentpane.setLayout(new FlowLayout());
jl1=new JLabel("Serial No");
jl2=new JLabel("Name");
jl3=new JLabel("Age");
jl4=new JLabel("Designation");
jl5=new JLabel("Date Of Birth");
jtf1=new JTextField(15);
jtf2=new JTextField(15);
jtf3=new JTextField(15);
jtf4=new JTextField(15);
jtf5=new JTextField(15);
result=new JLabel("Result");
jb=new JButton("Save");
contentpane.add(jl1);
contentpane.add(jl2);
contentpane.add(jl3);
contentpane.add(jl4);
contentpane.add(jl5);

contentpane.add(jtf1);
contentpane.add(jtf2);
contentpane.add(jtf3);
contentpane.add(jtf4);
contentpane.add(jtf5);

contentpane.add(result);
contentpane.add(jb);

setVisible(true);
setSize(900,900);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(ae.getSource().equals(jb))
{
String serialno=jtf1.getText();
int intF1=Integer.parseInt(serialno);
String strF2=jtf2.getText();
String age=jtf3.getText();
int intF3=Integer.parseInt(age);
String strF4=jtf4.getText();
String strF5=jtf5.getText();
Date dtF5=Date.valueOf(strF5);


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:TestSQL");
PreparedStatement ps=con.prepareStatement("insert into profile1 values(?,?,?,?,?)");
ps.setInt(1,intF1);
ps.setString(2,strF2);
ps.setInt(3,intF3);
ps.setString(4,strF4);
ps.setDate(5,dtF5);

ps.executeUpdate();

ps.close();
con.close();

result.setText("Record has been inserted");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public static void main(String[] args)
{
InsertGUI1 insertGUI1=new InsertGUI1("Test Frame for insert statement");
}

}

/* I gave inputs as following for SQL table

type length
serialno : 145 numeric 9
name : Ramesh RK varchar 50
age : 34 int 4
designation : Programmer varchar 50
Date Of Birth : 1973-07-31 datetime 8

I got error as

"java.sql.SQLException:

[Microsoft] [ODBC SQL Server Driver] Optional feature not implemented

*/
Hi,
When I tried for compiling servlet,that has a POJO(model) creation in its code,I got "package does not exists" error for the POJO even though I gave the import statement.Also I have specified the classpath for the POJO.How can I resolve this problem?

Thank and regards,
Ramesh RK
14 years ago
Hi,
I have a doubt about setting date format for database field when I use java.sql.Date format in my java applications.There is a collision between SQL Server's "month/day/year' format and java.sql.Date class' "year/month/day" format.If I tried to store "year/month/day" format in SQL Server table I got the error "Microsoft ODBC SQLException, Optional feature not implemented". How can I store that kind of date in SQL Server? Can I create american date format in java?How?

Yours faithfully,
Ramesh RK
Hi,
I tried to execute insert query using String and integer variables I got
"String or binary data would be truncated" error I tried for many times .But I did not get the insertion of data.Give me an complete requested insert statement example.
Hi,
I had an error as "unclosed string literal" when i tried to give &textbox.getText()& as an input for a insert statement as follows

Connection con=DriverManager.getConnection("jdbc:odbc:AllSql");
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into Login
values(&text1.getText()&,&text2.getText()&");

help me to insert values through input GUI Components to database tables.