|
Can u send me some links about that ?
|
|
|
|
|
|
|
Hi there .. Im new to Cloud computing but I have developed much apps in C#. I want to develop a SaaS application in Java, plz tell me what I need to learn in java except its basics which I have learnt. Should I call SaaS a web application? do i have to learn JavaScript to develop SaaS ?. Plz any one that can guide me or give me a list "What I have to Do"
SamHash
|
|
|
|
|
This is really a Google question[^], rather than a Java question.
Use the best guess
|
|
|
|
|
Sir , I want to ask that is there essential to use a PaaS or IaaS provided by google, amazon and Microsoft? I just learned that there is a software -- or whatever that is called specifically -- named "CloudSim" Which can be used to create your own cloud on a server by using cloud architecture and by a VM. I dont know how to use them, and is this is good to have your own cloud than using others infrastructure ?
|
|
|
|
|
Sorry, but I have no idea, this forum is for Java programming questions. Maybe you would get a better answer to your query in the Cloud Computing[^] or Quick Answers[^] forums.
Use the best guess
|
|
|
|
|
Hi, I am new to java and am working on a sales tax project. And I can't seem to even get the project tested as it is. Can anyone help me please?
The full error message I get is
java.lang.NullPointerExpection at SaleBad.total(SaleBad.java:42)
and the code line it highlights is in the method below:
public double total()
{
double sum = 0;
for (SalesLine s: saleLines) {
sum = sum + s.price();
}
if (state.equals( "AL")) sum = sum * 1.07;else
if (state.equals( "AK")) sum = sum * 1.04; else
Thank you!
|
|
|
|
|
|
Same question happened before to me. refer the following link. u ll find the answer Null point exception[^]
|
|
|
|
|
Im goin to a online bank assignment in java using DAO technigues with mysql.it is not printing an error or exception.but it always jumps to false part.here my code, please tell where I go wrong and how to fix it..
Login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<title>Insert title here
Login
UserName:
Password:
<%=request.getAttribute("loginMsg") %>
UserServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String operation = request.getParameter("operation");
if(operation!=null && operation.equalsIgnoreCase("login")){
loginDetail(request,response);
}else if(operation!=null && operation.equalsIgnoreCase("login")){
logout(request,response);
}
}
private void loginDetail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
User u = new User();
UserService us =new UserServiceImpl() ;
String Uname = request.getParameter("txtUname");
String Pwrd = request.getParameter("txtPwrd");
u.setUname(Uname);
u.setPwrd(Pwrd);
System.out.println(Uname+""+Pwrd);
try {
if(us.Userlogin(u.getUname(),u.getPwrd())){
String message = "Thank you, " + Uname +"..You are now logged into the system";
HttpSession session = request.getSession(true);
session.setAttribute("username", Uname);
session.setAttribute("password", Pwrd);
response.setContentType("text/html");
request.setAttribute("message", message);
request.getRequestDispatcher("/Menu.jsp").forward(request, response);
}else {
String message = "You have to register first or check Your user name password again!";
request.setAttribute("loginMsg", message);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/Login.jsp");
rd.forward(request, response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
UserServiceImpl.java
@Override
public boolean Userlogin(String Uname, String Pwrd) {
// TODO Auto-generated method stub
boolean result=false;
UserDAO udoi = new UserDAOImpl();
User user = new User();
System.out.println("ppp");
user.setUname(Uname);
user.setPwrd(Pwrd);
System.out.println("//////");
System.out.println(user.getUname()+user.getPwrd());
if(user!=null){
System.out.println(user.getUname()+user.getPwrd());
result = udoi.getLoginDetail(Uname, Pwrd);
//result=true;
}
return result;
}
UserDAOImpl.java
@Override
public boolean getLoginDetail(String Uname, String Pwrd) {
// TODO Auto-generated method stub
System.out.println(Uname+"++"+Pwrd);
Connection conn=null;
ResultSet rs=null;
boolean SUCCESS=false;
try {
conn=getConnection();
//String sql="SELECT * FROM login WHERE UserName='amal' and password='secret' ";
String sql="SELECT * FROM login WHERE UserName='" + Uname + "' and Password='"+ Pwrd + "' ";
System.out.println(sql);
Statement stmt=conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println("ddddddddddddddddd" + rs==null);
System.out.println("sssssssssssssssss" + rs.next());
while(rs.next()) {
System.out.println(Uname+"*_*"+Pwrd);
String uname=rs.getString("UserName");
String password=rs.getString("Password");
System.out.println(Uname+"***"+Pwrd);
if ((uname.equals(Uname)) && (password.equals(Pwrd))){
SUCCESS=true;
}else {
SUCCESS=false;
}
}
}
catch (Exception e){
e.printStackTrace();
}finally {
try {
conn.close();
rs.close();
} catch (SQLException ex) {
Logger.getLogger(AccountDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
return SUCCESS;
}
private Connection getConnection() {
// TODO Auto-generated method stub
ConnectionFactory cf = new ConnectionFactory();
Connection conn = null;
try {
conn = cf.getConnection();
} catch (SQLException ex) {
Logger.getLogger(AccountDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return conn;
}
EveryImpl file has it's interfaceclass.please tell me where I go wrong. Thank you!
|
|
|
|
|
Cross post.
Regards
Shubhashish
|
|
|
|
|
Im goin to a online bank assignment in java using DAO technigues with mysql.it is not printing an error or exception.but it always jumps to false part.here my code, please tell where I go wrong and how to fix it..
Login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form name="input" action="login" method="post">
<h1>Login</h1><br>
UserName: <input type="text" name="txtUname"><br>
Password: <input type="password" name="txtPwrd"><br>
<input type="submit" value="Login" onclick= <a href="main/Servelet"</a> >
<input type="hidden" name="operation" value="login">
<p><%=request.getAttribute("loginMsg") %></p>
</form>
</body>
</html>
UserServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String operation = request.getParameter("operation");
if(operation!=null && operation.equalsIgnoreCase("login")){
loginDetail(request,response);
}else if(operation!=null && operation.equalsIgnoreCase("login")){
logout(request,response);
}
}
private void loginDetail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
User u = new User();
UserService us =new UserServiceImpl() ;
String Uname = request.getParameter("txtUname");
String Pwrd = request.getParameter("txtPwrd");
u.setUname(Uname);
u.setPwrd(Pwrd);
System.out.println(Uname+""+Pwrd);
try {
if(us.Userlogin(u.getUname(),u.getPwrd())){
String message = "Thank you, " + Uname +"..You are now logged into the system";
HttpSession session = request.getSession(true);
session.setAttribute("username", Uname);
session.setAttribute("password", Pwrd);
response.setContentType("text/html");
request.setAttribute("message", message);
request.getRequestDispatcher("/Menu.jsp").forward(request, response);
}else {
String message = "You have to register first or check Your user name password again!";
request.setAttribute("loginMsg", message);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/Login.jsp");
rd.forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
UserServiceImpl.java
@Override
public boolean Userlogin(String Uname, String Pwrd) {
boolean result=false;
UserDAO udoi = new UserDAOImpl();
User user = new User();
System.out.println("ppp");
user.setUname(Uname);
user.setPwrd(Pwrd);
System.out.println("//////");
System.out.println(user.getUname()+user.getPwrd());
if(user!=null){
System.out.println(user.getUname()+user.getPwrd());
result = udoi.getLoginDetail(Uname, Pwrd);
}
return result;
}
UserDAOImpl.java
@Override
public boolean getLoginDetail(String Uname, String Pwrd) {
System.out.println(Uname+"++"+Pwrd);
Connection conn=null;
ResultSet rs=null;
boolean SUCCESS=false;
try {
conn=getConnection();
String sql="SELECT * FROM login WHERE UserName='" + Uname + "' and Password='"+ Pwrd + "' ";
System.out.println(sql);
Statement stmt=conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println("ddddddddddddddddd" + rs==null);
System.out.println("sssssssssssssssss" + rs.next());
while(rs.next()) {
System.out.println(Uname+"*_*"+Pwrd);
String uname=rs.getString("UserName");
String password=rs.getString("Password");
System.out.println(Uname+"***"+Pwrd);
if ((uname.equals(Uname)) && (password.equals(Pwrd))){
SUCCESS=true;
}else {
SUCCESS=false;
}
}
}
catch (Exception e){
e.printStackTrace();
}finally {
try {
conn.close();
rs.close();
} catch (SQLException ex) {
Logger.getLogger(AccountDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
return SUCCESS;
}
private Connection getConnection() {
ConnectionFactory cf = new ConnectionFactory();
Connection conn = null;
try {
conn = cf.getConnection();
} catch (SQLException ex) {
Logger.getLogger(AccountDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return conn;
}
EveryImpl file has it's interfaceclass.please tell me where I go wrong. Thank you!
|
|
|
|
|
ppp
//////
2222
2222
22++22
Welcome
Connected
SELECT * FROM login WHERE UserName='22' and Password='22'
false
ssssssssssssssssstrue
This is the Output..when i enter a true login details..Still couldn;t find the error..
|
|
|
|
|
The problem is here. Your ResultSet return one row. First rs.next() point to the actual row returned. Again in while loop you use rs.next() so your resultSet move to the next row, and which has no row value(first row already read) so it return false and thus skip the while loop.
System.out.println("sssssssssssssssss" + rs.next());
while(rs.next()) {
Remove the sout.
<pre lang="java">
while(rs.next()) {
</pre>
Regards
Shubhashish
|
|
|
|
|
Thank u soo much..it is working perfectly now
|
|
|
|
|
welcome
Regards
Shubhashish
|
|
|
|
|
How can I use another class actionPerformed in another main class?
I want to use this class actionperformed
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.awt.Container;
import javax.swing.JOptionPane;
import java.awt.Frame;
import java.awt.event.*;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
public class SpringSample extends Frame implements ActionListener
{
JLabel F_namelbl = new JLabel("Username: ");
JLabel L_namelbl = new JLabel("Password: ");
JTextField tf_Fname = new JTextField(15);
JPasswordField tf_Lname = new JPasswordField(15);
JLabel Lbl_HW = new JLabel("< Login Area >");
JButton Btn = new JButton("Login");
JButton btn_cancel = new JButton("Cancel");
private static final long serialVersionUID = 1L;
SpringSample()
{
JFrame frame = new JFrame("Login Area!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = frame.getContentPane();
JPanel p = new JPanel(new SpringLayout());
SpringLayout layout = (new SpringLayout());
contentPane.setLayout(layout);
JPanel p1=new JPanel();
frame.add(p1);
contentPane.add(F_namelbl);
contentPane.add(L_namelbl);
contentPane.add(tf_Fname);
contentPane.add(tf_Lname);
contentPane.add(Lbl_HW);
contentPane.add(Btn);
contentPane.add(btn_cancel);
layout.putConstraint(SpringLayout.WEST, Lbl_HW, 140, SpringLayout.WEST, contentPane);
layout.putConstraint(SpringLayout.NORTH, Lbl_HW, 0, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.WEST, Lbl_HW, 140, SpringLayout.WEST, contentPane);
layout.putConstraint(SpringLayout.NORTH, Lbl_HW, 0, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.WEST, F_namelbl, 30, SpringLayout.WEST, contentPane);
layout.putConstraint(SpringLayout.NORTH, F_namelbl, 25, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.WEST, L_namelbl, 30, SpringLayout.WEST, contentPane);
layout.putConstraint(SpringLayout.NORTH, L_namelbl, 50, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.NORTH, tf_Fname, 25, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.WEST, tf_Fname, 15, SpringLayout.EAST, F_namelbl);
layout.putConstraint(SpringLayout.NORTH, tf_Lname, 50, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.WEST, tf_Lname, 15, SpringLayout.EAST, F_namelbl);
layout.putConstraint(SpringLayout.NORTH, Btn, 80, SpringLayout.NORTH, contentPane);
layout.putConstraint(SpringLayout.WEST, Btn, 110, SpringLayout.WEST, contentPane);
layout.putConstraint(SpringLayout.NORTH, btn_cancel, 80, SpringLayout.NORTH, p1);
layout.putConstraint(SpringLayout.WEST, btn_cancel, 200, SpringLayout.WEST, p1);
btn_cancel.addActionListener(this);
Btn.addActionListener(this);
frame.pack();
frame.setSize(350, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String args[])
{
new SpringSample();
Connectionstring();
try {
insertRecordIntoDbUserTable();
selectfromdb();
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
}
static Connection Connectionstring()
{
Connection con = null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
String conUrl = "jdbc:sqlserver://localhost:1433; databaseName=paytest; user=PC; password=; integratedSecurity=true;";
try
{
con = DriverManager.getConnection(conUrl);
JOptionPane.showMessageDialog(null,"Connection is open!","Connection",JOptionPane.WARNING_MESSAGE);
}
catch (SQLException e)
{
e.printStackTrace();
}
return con;
}
private static void insertRecordIntoDbUserTable() throws SQLException
{
Connection con = null;
Statement statement = null;
String insertTableSQL = "INSERT INTO LoginDetails" + "(Username, Password) " + "VALUES" + "('user1','user1')";
try
{
con = Connectionstring();
statement = con.createStatement();
System.out.println(insertTableSQL);
statement.executeUpdate(insertTableSQL);
JOptionPane.showMessageDialog(null,"Your Data has been Inserted","Data Inserted",JOptionPane.WARNING_MESSAGE);
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
finally
{
if (statement != null)
{
statement.close();
JOptionPane.showMessageDialog(null,"Statement is closed","Statement",JOptionPane.WARNING_MESSAGE);
}
if (con != null)
{
con.close();
JOptionPane.showMessageDialog(null,"Connection is closed!","Connection",JOptionPane.WARNING_MESSAGE);
}
}
}
private static void selectfromdb() throws SQLException
{
Statement stmt = Connectionstring().createStatement();
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails");
while (rs.next())
{
String lastName = rs.getString("Username");
String Pass = rs.getString("Password");
System.out.println(lastName + "" + Pass + "\n");
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == btn_cancel)
{
JOptionPane.showMessageDialog(null,"You have clicked on Cancel","button cancel",JOptionPane.WARNING_MESSAGE);
}
else if(e.getSource() == Btn)
{
JOptionPane.showMessageDialog(null,"You have clicked login","button login",JOptionPane.WARNING_MESSAGE);
}
}
}
I want to use in this class
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
public abstract class ConnectionDB
{
public static void main(String[] args)
{
SpringSample sp = new SpringSample();
try {
insertRecordIntoDbUserTable();
selectfromdb();
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
}
private static void insertRecordIntoDbUserTable() throws SQLException
{
Connection con = null;
Statement statement = null;
String insertTableSQL = "INSERT INTO LoginDetails" + "(Username, Password) " + "VALUES" + "('null2','tf_Lname')";
try
{
con = DBConnectionstring();
statement = con.createStatement();
System.out.println(insertTableSQL);
statement.executeUpdate(insertTableSQL);
JOptionPane.showMessageDialog(null,"Your Data has been Inserted","Data Inserted",JOptionPane.WARNING_MESSAGE);
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
finally
{
if (statement != null)
{
statement.close();
JOptionPane.showMessageDialog(null,"Statement is closed","Statement",JOptionPane.WARNING_MESSAGE);
}
if (con != null)
{
con.close();
JOptionPane.showMessageDialog(null,"Connection is closed!","Connection",JOptionPane.WARNING_MESSAGE);
}
}
}
private static void selectfromdb() throws SQLException
{
Statement stmt = DBConnectionstring().createStatement();
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails");
while (rs.next())
{
String lastName = rs.getString("Username");
String Pass = rs.getString("Password");
System.out.println(lastName + "" + Pass + "\n");
}
}
static Connection DBConnectionstring()
{
Connection con = null;
String conUrl = "jdbc:sqlserver://localhost:1433; databaseName=paytest; user=PC; password=; integratedSecurity=true;";
try
{
con = DriverManager.getConnection(conUrl);
JOptionPane.showMessageDialog(null,"Connection is open!","Connection",JOptionPane.WARNING_MESSAGE);
}
catch (SQLException e)
{
e.printStackTrace();
}
return con;
}
}
How can I do that?
|
|
|
|
|
Rather than dumping a lot of code, try explaining your problem in clear terms. If you need to call a method of a class then create an object of that class and call the method as normal. however, if that is not your question then please clarify.
Use the best guess
|
|
|
|
|
You can only register an event handler to an event source. So your first class is an event handler. And there fore you can use this to any of the event source which trigger that event. Something like this.
class Handler implements ActionPerformed{
public void actionPerformed(ActionEvent e) {}
}
}
class Source {
p s v main(){
JButton bt = new Jbutton("Ok");
bt.addActionListener(new Handler());
}
}
Regards
Shubhashish
|
|
|
|
|
Jvm has be written to have good speed in linux?
|
|
|
|
|
Please stop posting these questions. you have been told plenty of times that they are not valid for the programming forums.
Use the best guess
|
|
|
|
|
You are a funny person, why do I need to care what you said? This is a very good topic to discuss for anyone interest in Java, stop being funny alright?
|
|
|
|
|
crunchor wrote: Jvm has be written to have good speed in linux?
Of course it was, Do you really think that it would have been written to have poor performance?
|
|
|
|
|
|