473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Java, mysql, xml related problem.

I have created project management software with Java and MySql and i
works fine.
This applet gets and writes information directly to MySql database.

Problem is that those sqlClauses below(update and insert) should g
"through" xml "document" and i haven´t got idea how to do that.
If someone could give me advices or even tell me how I must modify m
code I would be very grateful.

My english is not so good, so my problem sentence could be little har
to understand, but please try. If it´s too hard to understand pleas
tell me even how can i save results of those clauses to xm
"document".

Here is part of main program:
Code
-------------------

void cmgUpdateNormalHours1_actionPerformed(ActionEvent e) { ///button update
if(e.getActionCommand().equals("Update"))
{
ResultSet Result;
String proj= txtProjectNumber.getText();//gets project number
String day= txtDate1.getText();//gets date
String paivitus = txtNormalHours1.getText(); //gets normalhours
int changes=0;

String sqlClause="select count(*) from hours where days ='"+day+"'";
Tietokantayhteys Conn = new Tietokantayhteys(); ///connection to the database
Result= Conn.Query(sqlClause);
String result=null; //different result than Result

try {
Result.next();
result=Result.getString(1);
} catch(Exception ex) {
ex.printStackTrace();
}

int tempa=Integer.parseInt(result);
if(tempa==1)
{
String sqlClause1 = "update hours set normalhours= '" + paivitus + "'" +
"where proj_id = " + proj + " and days ='" + day + "'";
tempa=Conn.UpdateQuery(sqlClause1);
}
if(tempa==0)
{
String sqlClause2= "insert into hours (proj_id, days, normalhours) " +
"values ("+proj+",'"+day+"','"+paivitus+"')";
tempa=Conn.UpdateQuery(sqlClause2);
}
-------------------
And here is database connection class which i have created:

Code
-------------------

package simple;
import java.sql.*;

public class Tietokantayhteys
{
///määritellään luokan tarvitsemat oliot
///define object which class need
Connection Conn;
Statement st;
ResultSet Result;

public Tietokantayhteys()
{

//open connection to database
try
{
///load database driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Conn = DriverManager.getConnection
( "jdbc:odbc:pro","root","");
//set start value to Statement object
st = Conn.createStatement();

} catch (Exception e)

{
e.printStackTrace();
}

}
// query method for select
public ResultSet Query(String sqlClause)
{

try {
Result = st.executeQuery(sqlClause);

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

return Result;
}
/// update method for update inquery
public int UpdateQuery(String sqlClause)
{

//saves how many changes has been made
int muutoksia=0;

try {
muutoksia = st.executeUpdate(sqlClause); ///<---muutoksia means == changes

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

return muutoksia;
}

////close all connections
public void suljeYhteys() ///<---means close connection
{
try {

st.close();
Conn.close();
} catch(Exception e)
{ e.printStackTrace();
}
}
}

-------------------
-
hiisikukk
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message105717.htm

Jul 20 '05 #1
0 2920

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: apchar | last post by:
I am trying to use php as a kind of servlet to act as a middle man between a java applet and mysql. I know java has jdbc but it's flakey and painful. php access to mysql is much nicer. So I have:...
11
by: Lem | last post by:
I get the error Exception in thread "main" java.lang.NoClassDefFoundError when I type java app2 in the command prompt. I've tried moving to the jre directory and typed java c:\app2\app2, but it...
2
by: Dan | last post by:
Hello. I have recently tried upgrading the MySql connector for my servlet from 2.0.4 to 3.0.9. I have found a minor limitation in 2.0.4 and was hoping that 3.0.9 would fix it. However, now I...
5
by: TZESENG | last post by:
DECEMBER 13, 2005 . Editions: N. America | Europe | Asia | Edition Preference News Analysis By Steve Hamm Source: http://www.businessweek.com/technology/content/dec2005/tc20051213_042973.htm...
2
jeffbroodwar
by: jeffbroodwar | last post by:
i'm currently working on a project about webservices. i tried to create an ordinary service that inserts data to the database. here's the code : ===================================================...
5
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql server with java application but when i try to compile,the compilation is successful and during execution i get the following message, ...
66
by: flarosa | last post by:
Hi, I'm wondering if I can get a reasonably civil (without starting any huge wars) opinion on how server-side PHP compares to server-side Java. I've been strictly a Java developer for almost...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
3
by: Joshepmichel | last post by:
Please to help me to following problem I want to do this 1. create Table Name MEMBER on the Database Name "mytestdb", 2. Add the Values to the Table through the Key board Inputs during running...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.