![]() |
|
|
#1 |
|
Junior Member
Join Date: Oct 2004
Posts: 2
|
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 |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
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. |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2004
Posts: 2
|
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() ); } } } |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Oct 2004
Posts: 13
|
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. |
|
|
|
|
|
#5 |
|
Member
Join Date: Feb 2005
Location: ANtwerp - Belgium
Posts: 34
|
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 |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
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 |