MySqlTalk.com  

Go Back   MySqlTalk.com > Programming Languages and MySQL > Java
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread
Old 10-26-2004, 03:55 PM   #1
caupena
Junior Member
 
Join Date: Oct 2004
Posts: 2 caupena is on a distinguished road
Where is th error

Good evening
I i'm a beginer user of My SQL, and a have a problem, and i dont`t know how to solve

i compar tree variables with the bd, and if this 3 variables existing in the data base i update the table, and the code are thath under this text
A try a lot of syntax, but all the time my sql says i have a syntax error
Anybody can help me?
Excuse my poor english, i made my best

String query="UPDATE gsdep SET " +
"emp='" + fields.emp.getText() +
"', fil='" + fields.id.getText() +
"', ende='" + fields.dept.getText() +
"', razc='" + fields.first.getText() +
"', ende='" + fields.last.getText() +
"', bair='" + fields.address.getText() +
"', cida='" + fields.city.getText() +
"', esta='" +
fields.state.getText() +
"', cepe='" + fields.zip.getText() +
"', pais='" + fields.country.getText() +
"', email='" +
fields.email.getText() +
"', fone='" + fields.home.getText() +
"', fax='" + fields.fax.getText() +
the problem==> "' WHERE fil= + fields.id.getText()AND emp=fields.emp.getText() AND dept=fields.dept.getText()'";//THE PROBLEM IS IN THIS LINE<<<=====http://www.mysqltalk.com/forums/newthread.php?do=newthread&f=4#

Thanks in advanced
Carlos Pena-Brazil
caupena is offline   Fork this post Reply With Quote
Old 10-26-2004, 11:36 PM   #2
Administrator
Administrator
 
Join Date: Jun 2004
Posts: 383 Administrator is on a distinguished road
Re: Where is th error

What programming language are you interfacing to mysql with? Your post seems to have gotten messed up towards the end. Can you try to rephrase it?

Or maybe ask the question in your native tongue, maybe someone will be able to translate it? Because we may also have a bit of a language problem too.
Administrator is offline   Fork this post Reply With Quote
Old 10-27-2004, 07:20 AM   #3
caupena
Junior Member
 
Join Date: Oct 2004
Posts: 2 caupena is on a distinguished road
Re: Where is the error

I use Java whit MySQL
The original code are under this line
Thanks in Advanced
Carlos Pena-Brazil

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

public class UpdateRecord implements ActionListener {
private ScrollingPanel fields;
private JTextArea output;
private Connection connection;

public UpdateRecord( Connection c, ScrollingPanel f,
JTextArea o )
{
connection = c;
fields = f;
output = o;
}

public void actionPerformed( ActionEvent e )
{
try {
Statement statement = connection.createStatement();

if ( ! fields.id.getText().equals( "" ) ) {

String query="UPDATE gsdep SET " +
"emp='" + fields.emp.getText() +
"', fil='" + fields.id.getText() +
"', dept='" + fields.dept.getText() +
"', razc='" + fields.first.getText() +
"', ende='" + fields.last.getText() +
"', bair='" + fields.address.getText() +
"', cida='" + fields.city.getText() +
"', esta='" +
fields.state.getText() +
"', cepe='" + fields.zip.getText() +
"', pais='" + fields.country.getText() +
"', email='" +
fields.email.getText() +
"', fone='" + fields.home.getText() +
"', fax='" + fields.fax.getText() +
this Line====>>>> "WHERE emp=fields.emp.getText() AND fil=fields.id.getText() AND dept=fields.dept.getText()" ;<<<====end here
output.append( "\nSending query: " +
connection.nativeSQL( query ) + "\n" );

int result = statement.executeUpdate( query );

if ( result == 1 )
output.append( "\nUpdate successful\n" );
else {
output.append( "\nUpdate failed\n" );
fields.first.setText( "" );
fields.last.setText( "" );
fields.address.setText( "" );
fields.city.setText( "" );
fields.state.setText( "" );
fields.zip.setText( "" );
fields.country.setText( "" );
fields.email.setText( "" );
fields.home.setText( "" );
fields.fax.setText( "" );
}

statement.close();
}
else
output.append( "\nVoce Pode apenas atualizar/alterar\n " +
"um registro existente. Use Pesquisa para \n" +
"localizar o registro e ai \n" +
"modifique a informação e pressione\n " +
"editar para termjinar o processo.\n" );
}
catch ( SQLException sqlex ) {
sqlex.printStackTrace();
output.append( sqlex.toString() );
}
}
}
caupena is offline   Fork this post Reply With Quote
Old 10-30-2004, 10:22 AM   #4
HTTPguru
Junior Member
 
Join Date: Oct 2004
Posts: 13 HTTPguru is on a distinguished road
Re: Where is th error

well, did u connect the app with my sql properly

what is the sysntax error and what line does it show.

I prob recommend you to use Access which has an easy interface esp with java or asp.

I donot say that it cannot be done with mysql, but with little heck.
HTTPguru is offline   Fork this post Reply With Quote
Old 04-30-2005, 06:21 AM   #5
gertcuppens
Member
 
Join Date: Feb 2005
Location: ANtwerp - Belgium
Posts: 34 gertcuppens is on a distinguished road
Re: Where is th error

I've written several web applications using MySQL and Java and I've never had an error. But you should try to start your MySQL GUI and write your SQL statement in this GUI. If you don't have a GUI, try Navicat. You can download it at www.navicat.com and try it for 30 days.

Anyway, as soon as your SQL statement is correct, import it in Java.
This way, you're sure that MySQL won't have any trouble with the syntax.

If you want an example, let me know. I'll be happy to provide you with some java code
gertcuppens is offline   Fork this post Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
error 1064 ?? Louppy General 10 02-25-2005 01:36 PM
Error on my Message Board toprobroy General 4 02-07-2005 05:29 PM
illegal mix of collation error netpriest General 1 02-05-2005 08:44 AM
Receiving error when Importing Access mchu Navicat Support 2 11-18-2004 12:10 AM
SQL Syntax Near Error coolest PHP 1 10-20-2004 02:01 PM



All times are GMT -4. The time now is 12:31 PM.



Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Google
  Web http://www.mysqltalk.com
DISCLAIMERS:
1. We have no commercial interest in this site.
Banner Ads and Subscriptions will only be used to help pay for hosting and maintenance costs.
2. MySQLTalk.com is NOT affiliated with MySQL AB in any way.
3. MySQLTalk.com is NOT endorsed by MySQL AB in any way.
4. Please do not post any content that is harmful to MySQL or MySQL AB, meaning no misleading or obsolete information will be tolerated.
Well-founded constructive criticism meant to help the community is permitted.
5. This website is founded with the goal of improving the MySQL community.
We not only tolerate newbies, we encourage them.
Please do not ask newbies to "read the manual".