magic zha

Greenhorn
+ Follow
since Mar 25, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by magic zha

hi, everyone, I am writing a CMP bean. And it is very simple, and now I need to insert a row with create(). However, when I invoke create(), I get such exceptions:


Executing SQL: SELECT COUNT(*) FROM users WHERE
2006-05-23 15:36:22,328 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.User] Error checking if entity exists
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1



I think I did right in all the files, could you tell what is the possible problem?
Thanks a lot!
Hi, everyone:
I am new to EJB. Who can give me some EJB demos,both ejb2.1 and ejb3.0 are OK.
Thank you!
Refer to some JDBC tutorials.
It is very easy.I think you will solve it in 20 minutes.
I think it must be:
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19 years ago
I have tried , but still failed.
The programe always display a dialog which indicates the URL=null,and can't display the image.
I use the command:
jar cvfm ImageInJar.jar manifest.mf ImageInJar.class ImagePanel.class TEST.gif
19 years ago
I have tried , but still failed.
The programe always display a dialog which indicates the URL=null,and can't display the image.
I use the command:
jar cvfm ImageInJar.jar manifest.mf ImageInJar.class ImagePanel.class TEST.gif
19 years ago
I have such program:

I have generate the jar file by command:
jar cvfm Test.jar mymanifest.mf TestPanel.class
when I double click it,the programe worked and the picture displayed.
But when move the jar file to other place,why dosen't the picture display?
Please help me ,thank you!
19 years ago
I tried,but it makes nothing!
19 years ago
I get this sample from a book about Servlets,this servlet is used to bind or unbound an object ,which implements the HttpSessionBindingListener,to an attribute in the session.Now following is the whole code:


The object got from the is always null.why?
19 years ago
This servlet will create an HttpSession.The user can enter an attribute name,and if he clicks "Bind",an object will be
bound to the attribute.And if he clicks "Unbind" next time,the will remove the object from the session.
But when i want to unbind the object,and i get the object from the session, it always return NULL!
Why? Following is the code:
import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;

public class TestSession extends HttpServlet {

public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();

HttpSession mySession = request.getSession(true);

String sessionName = (String) request.getParameter("Name");

if (sessionName == null) {
sessionName = "";
}

out.println("<HTML>");
out.println("<HEAD><TITLE>Session Binding</TITLE></HTML>");
out.println("<BODY>");
out.println("<FORM METHOD=\"POST\">");
out.println("Name of the session attribute:");
out.println("<INPUT TYPE=\"TEXT\" NAME=\"Name\" VALUE=\"" + sessionName
+ "\"><P>");
out.println("<INPUT TYPE=\"SUBMIT\" NAME=\"Bind\" VALUE=\"Bind\">");
out.println("<INPUT TYPE=\"SUBMIT\" NAME=\"Unbind\" VALUE=\"Unbind\">");
out.println("</FORM>");

if (!sessionName.equals("")) {
if (request.getParameter("Bind") != null) {
String str = new String("Bind");

mySession.setAttribute(sessionName, str);
} else if (request.getParameter("Unbind") != null) {
String str = (String) mySession.getAttribute(sessionName); // it always return NULL! Why?
if (str != null) {
mySession.removeAttribute(request.getParameter("Name"));
}

}
}

out.println("</BODY></HTML>");
}
}
19 years ago
I get the code from a book about Servlets:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class ColorSession extends HttpServlet {

public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String name;
String color;
Integer hitCounts;

HttpSession mySession = request.getSession(true);

response.setContentType("text/html");

PrintWriter out = response.getWriter();

if (mySession.isNew()) { //html page1
out.println("<HTML>");
out.println("<HEAD><TITLE>Select Color</TITLE></HEAD>");
out.println("<BODY>");
out.println("<FORM METHOD=\"POST\" ACTION=\"ColorSession\">");
out.println("Please select your color:<BR>");

out.println("<INPUT TYPE=\"RADIO\" NAME=\"bcolor\" "
+ "VALUE=\"white\">White<BR>");
out.println("<INPUT TYPE=\"RADIO\" NAME=\"bcolor\" "
+ "VALUE=\"red\">Red<BR>");
out.println("<INPUT TYPE=\"RADIO\" NAME=\"bcolor\" "
+ "VALUE=\"green\">Green<BR>");
out.println("<INPUT TYPE=\"RADIO\" NAME=\"bcolor\" "
+ "VALUE=\"blue\">Blue<P>");

out.println("Please enter your name:<BR>");
out.println("<INPUT TYPE=\"TEXT\" NAME=\"name\" "
+ "SIZE=\"25\"><P>");

out.println("<INPUT TYPE=\"SUBMIT\" VALUE=\"Submit\">");
out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");
} else {
String bcolor = request.getParameter("bcolor");
if (bcolor != null) {
if (bcolor.equals("red")) {
color = "#FF0000";
} else if (bcolor.equals("green")) {
color = "#00FF00";
} else if (bcolor.equals("blue")) {
color = "#0000FF";
} else {
color = "FFFFFF";
}

name = request.getParameter("name");
hitCounts = new Integer(1);
mySession.setAttribute("bcolor", color);
mySession.setAttribute("hitCounts", hitCounts);
mySession.setAttribute("name", name);
} else {
color = (String) mySession.getAttribute("bcolor");
name = (String) mySession.getAttribute("name");
hitCounts = (Integer) mySession.getAttribute("hitCounts");
}

mySession.setAttribute("hitCounts", new Integer(hitCounts
.intValue() + 1));

out.println("<HTML>"); //html page2
out.println("<HEAD><TITLE>Color Select</TITLE></HEAD>");
out.println("<BODY BGCOLOR=\"" + color + "\">");
out.println("<H2>Hello " + name + "!</H2>");
out.println("<H3>You have requested this page " + hitCounts
+ "times.<BR></H3>");
out.println("<A HREF=\"ColorSession\">Reload Page</A>");
out.println("</BODY>");
out.println("</HTML>");
}
}
}

This servlet creates a HttpSession in order to store the user's name,preffer color and the times it has been accessed.
When it is accessed for the first time ,it will create a new session and display a html page to ask the user enter
his color and name. And after this it will display the information about the session.But,when i click the submit button in
the page1,it only display the same page(page1),not page2!
I don't know why!How can i make it do the things i want to?
19 years ago
Thank you!
Can you tell a simple way to check if it has a decimal part?
19 years ago
Sorry , i don't actually know what you mean.
For example, when the user enter in the instruction:"50 + 10" or "50.5 + 10",how can i tell the first number is an integer or a float?
19 years ago
When i get a variable which may be int , float ,long or double,
how can i actually know what it is?
19 years ago