Accesing mysql database from threads
Hi
dont know if this is the right place for this
I'm building a server-client application, on sever's side I create a thread for every client who can request several operations over a mysql database (insert, delete, update, etc), at some point 2 clients can request the same operation over the same registry (2 clients trying to delete the same registry, for example), I try to avoid that to happend, so before doing any operation over the database I check the correct status (a registry must exist to delete, or not exist to create, for example), this is the code that makes that (for inserting a registry):
//first I make sure the registry does not exist
sql = "SELECT id_grupo FROM adm_grupo WHERE nombre_grupo = '" + nomGrupo + "'";
res = bd.ConsultarSQL(sql);
//If already exist, the operation is rejected
if (res.next()) {
EnviarError("Error al Crear el Grupo: Ya existe ese nombre");
return -1;
//Check point ends
//If not, the insert statement is made
sql = "INSERT INTO adm_grupo VALUES (NULL,'" + nomGrupo + "','N')";however, since it could be 2 threads (every thread is an object) doing that, the first one can pass the check point and stop because its processor time is over, so the second can start its insert process and pass the check point too (because the first one didn't have enough time to insert the registry), then both registries are inserted causing a logical error, I thought in fixing that problem using the synchronized keyword for the functions, but I read that keyword blocks 1 object that can be accesed for several threads, but in my case I have several threads, everyone accesing its own object, so I'm not sure if the synchronized will work, I dont know any other solution to this,
thnx in advance for any help
Sure. But test it. You'll need to test it regardless, just to make sure it all works.
In general, I usually prefer to have the backup tool create the initial SQL database archive on the primary server, zip it, and to then have the backup server in a trusted network location pull the database archive over to the backup server. (It can then unzip it or process it as needed.) With this, the primary server doesn't have access to the backups, nor to the backup server. This intended to isolate the access that a breach of the primary server might permit.
Similar Messages
-
I can't connect to MySQL database from The JSP Standard Tag Library
Hi All !
I have a problem, please help me anybody !
I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java\jdk1.5.0_10\jre\lib\ext\mysql-connector-java-3.1.13-bin.jar) and in War project folder �WEB-INF/lib� and in [TomcatServer]\common\lib.
I have in folder�WEB-INF/lib� following files:
antlr.jar
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-fileupload.jar
commons-logging.jar
commons-validator.jar
jakarta-oro.jar
jsf-api.jar
jsf-impl.jar
jstl.jar
mysql-connector-java-3.1.13-bin.jar
standard.jar
struts.jar
I'm using:
NetBeans 5.5 Build200610171010 (bundled Tomcat 5.5.17)
Ent.Pack 20061020 Visual Wb Pack 061103
OS WinXP SP2
Java 1.5.0_10
MySQL 5.0.18-nt
1:<%@page contentType="text/html"%>
2:<%@page pageEncoding="UTF-8"%>
8: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
9: <%@taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
10:
11: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
12: "http://www.w3.org/TR/html4/loose.dtd">
13:
14: <sql:setDataSource var="ds"
15: driver="com.mysql.jdbc.Driver"
16: url="jdbc:mysql://localhost:3306/test"
17: user="root"
18: password="xxxx"/>
19:
20:
21:<sql:query sql="select name, age from People" var="res"
22: dataSource="${ds}"/>
I have received report on mistake when entered code at the top:
�/index.jsp [21;0] According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions�
I used instead of (dataSource="${ds}")->(dataSource="ds") but this did not work.
After build and run I have received
=========================================START=================================
HTTP Status 500
type Exception report:
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
Apache Tomcat/5.5.17
=======================================END================================
Error: "According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions" - but according to documentation such parameter possible.
BUT WHEN JOINING With DATABASE FROM SERVLET ALL WORK FINE.
I read this doc - [http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html], this applicable if I Tomcat Admin, but i'am not Admin
I simply user, i.e. I want to place its database on virtual host (Tomcat+(JSP-JSTL)+MySQL).
There is idea how can resolve this problem
Thank you in advance ;)For all how have similar problem.
Decision instead of these ways
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
it is necessary to indicate these
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -
Is it possible to read a mySQL database from an ABAP report?
We have some information stored in a mySQL database which is now required on ABAP reports.
Is it possible to read the mySQL database from an ABAP report? I'm still a bit confused on that.
So far I have setup DBCO with information about the mySQL server using MMS as the DBS because mySQL was not an option. I have made sure we have the latest dbmssslib.dll installed.
When I try to run the following code
EXEC SQL.
CONNECT TO :con
ENDEXEC.
I get error: SQL Server does not exist or access denied.
Then I have tried to connect using the function CHECK_CONNECTION_SDB.
I get the following messages in the return table:
1 OS-AppServ:Windows NT
2 dbmcli_neg: no_client_software
3 dbmrfc_c_neg: no_client_software
4 dbmrfc_s_neg: no_client_software
5 sql_neg
6 work_proc: 1
Does anyone know what I need to do to connect to the mySQL database.
Thank you
KarenThank you for your reply. I've gone through all the documentation you sent and much more and I'm still not sure what the problem is.
One thing that concerns me is that this all relates to MS SQL server and I'm trying to link to a mySQL database. Is this even possible?
Some posts talk about changing Oracle settings and having J2EE installed. Is this necessary to connect to a mySQL database via ABAP?
Which user should I enter into DBCO? Is it the mySQL server user or a SAP user? Does the person in charge of the mySQL database need to add any permissions for SAP to access the database or is that done by the user in DBCO?
Does anyone have any more advice?
Thank you
Karen
Also, does anyone know what the messages from the CHECK_CONNECTION_SDB function mean
1 OS-AppServ:Windows NT
2 dbmcli_neg: no_client_software
3 dbmrfc_c_neg: no_client_software
4 dbmrfc_s_neg: no_client_software
5 sql_neg
6 work_proc: 1
Edited by: Karen Dean on Oct 6, 2009 4:44 AM -
Accessing mySQL database from Labview PDA
Hi,
Has anyone tried writing data to a mySQL database or any other database for that matter using the Labview PDA module? I know it's easy to do from Labview and you have to download the ODBC drivers to get it working but I don't think these drivers are available for Windows Mobile (I've seen XP and Linux drivers only). Any help would be appreciated.
ThanksHello,
I don't have experience with this, but you might look into the following:
1. remote connections: http://www.geekzone.co.nz/content.asp?contentid=2656
2. this thread seems to indicate .NET doesn't support it yet (but it's over a year old...): http://forums.mysql.com/read.php?38,73109,73109
3. Another option - you can use VI Server to have your PDA VI call a VI on your host machine if they are networked... there is an example of this that ships with LabVIEW PDA I think - check it out! Thus, if the db is on your host machine, you could write your host VI, and have your PDA VI call it etc.
I hope this helps!
Best Regards,
JLS
Best,
JLS
Sixclear -
Accessing mysql database from oracle using dg4odbc
I've been trying to create a database link from a MySQL database to Oracle using the Oracle dg4odbc gateway. I downloaded and installed DataDirect's ODBC package which includes mysql ODBC library (ddmysql24.so) and a generic ODBC libary (libodbc.so). After creating the DSN in odbc.ini, I tested it and it can connect to the mysql database. Then I created the init{SID}.ora file in hs/admin directory, added dg4odbc lines in the listener.ora, and added lines in tnsnames.ora. Then I tnspinged the new SID with success. Finally, I created the database link. However, when I tried to access the database link using the commands "select * from mdl_user@moodle;", I got the ORA-28500 error like the following:
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[DataDirect][ODBC 20101 driver][20101]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 '"mdl_user"' at line 1
ORA-02063: preceding 2 lines from MOODLE
My mysql database is utf8 by default. Do I have to use latin1?
It seems to me that the dg4odbc translates the sql commands incorrectly (having double quotes around the selected table).
Any help is greatly appreciated.
JeffreyThe syntax error occures for example when MySQL isn't running in ANSI mode and thus does not allow double quotes around the objects. DG4ODBC 11.1.0.6 by default always adds double quotes to table/column/view names.
A quick test to check if you hit the double quote issue would be to set the MySQL DB into ANSI mode:
- Open SQL*Plus
- execute:
DECLARE
ret integer;
c integer;
BEGIN
c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@moodle;
DBMS_HS_PASSTHROUGH.PARSE@moodle(c, 'SET SESSION SQL_MODE=''ANSI_QUOTES'';');
ret := DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@moodle(c);
dbms_output.put_line(ret ||' passthrough output');
DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@moodle(c);
END;
- Now run your select statement
=> if it now works, you can permanently change the MySQL config to be ANSI compliant or you can apply the 11.1.0.7 patchset to DG4ODBC. -
Need help connecting a remote MySql database from Iphone
Hi, i need to connect to a remote MySql DataBase in windows from IPhone but..... i'm a noob with Xcode and Objective-C.
Can someone help me or explain me the way to do it plz?
Message was edited by: Krovax87
Message was edited by: Krovax87I do not think MCPKit will help you on the iPhone. It is just an Objective-C wrapper around the standard mysql libraries which are not available for the iPhone. Your best bet would be to post on the mysql forums and see if you can get any help.
You can try extracting the mysql client library source code into a separate static library project, and see if you can get it to build for the iPhone. -
Error accessing mysql database from a remote host
Hi all,
I'm running the following PL/SQL script and encountered some errors. The MySQL server is hosted off campus by a hosting company. However, when I run the same script against a MySQL database server hosted on campus, the script works fine. Here's the error:
ERROR at line 3:
ORA-04052: error occurred when looking up remote object
cmswhit_odbc13.mdl_user@RLTEST
ORA-00604: error occurred at recursive SQL level 1
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[MySQL][ODBC 5.1 Driver][mysqld-4.1.22-standard]SELECT command denied to user
'cmswhit_odbc13'@'192.160.216.13' for table 'mdl_user'
ORA-02063: preceding 2 lines from RLTEST
Here's the script:
sqlplus -s <<endofit
$USERPASS
set serveroutput on;
DECLARE
user_name varchar2(30);
moo_user_name varchar2(300);
routine VARCHAR2(40);
cntr NUMBER(8);
CURSOR read_saradap is
select gobtpac_external_user
from gobtpac
where gobtpac_external_user in ('greenup','yfeng');
CURSOR read_mdl_user is
select "username" from "mdl_user"@rltest where "username" = user_name;
-- E N D O F C U R S O R S --
BEGIN
dbms_output.enable(1000000000);
-- STEP 1: Read through Banner
cntr := 0;
OPEN read_saradap;
LOOP
routine := 'Read applicant';
-- Read an applicant record
dbms_output.put_line('Reading Banner user');
FETCH read_saradap INTO user_name;
EXIT WHEN read_saradap%NOTFOUND;
dbms_output.put_line('Read Banner username=' || user_name);
cntr := cntr + 1;
-- Read the Moodle user;
routine := 'Read moodle user';
OPEN read_mdl_user;
FETCH read_mdl_user INTO moo_user_name;
IF read_mdl_user%NOTFOUND THEN
dbms_output.put_line('Moodle user not found');
ELSE
dbms_output.put_line('Read Moodle username=' || moo_user_name);
END IF;
CLOSE read_mdl_user;
END LOOP;
rollback;
CLOSE read_saradap;
dbms_output.put_line('Total processed: ' || cntr);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLCODE);
dbms_output.put_line(SQLERRM);
dbms_output.put_line('Error user=' || user_name);
dbms_output.put_line(routine);
END;
EXIT;
endofitThe error seems to be quite clear: the user 'cmswhit_odbc13'@'192.160.216.13' lacks the SELECT privilege on the 'mdl_user' table...
Max
http://oracleitalia.wordpress.com -
Issue in accesing the database from osb10.3.1
Hi All,
I want to call database from osb10.3.1
Can anyone please tell me how can I configure the database adapter and use the jca protol to access the database tables in osb10.3.1
Also which Jdeveloper version I should use for configuring the database adapter in Jdeveloper(if required)
Thanks in Advance!!Hi Roshni,
There is a very good article written by Guido Schmutz on this...
Oracle Service Bus 11g and DB Adapter: a more integrated approach!
http://guidoschmutz.wordpress.com/2010/08/08/oracle-service-bus-11g-and-db-adapter-a-different-more-integrated-approach/
Remember! It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts).
https://forums.oracle.com/forums/ann.jspa?annID=893
Cheers,
Vlad -
CONNECTING TO MySql DATABASE FROM Jdeveloper
Hi,
How can i connect to MySql database form Oracle Jdeveloper version 11.1.2.0.0.
I was trying to create connection using create database connection dialog box but it is giving this error:
Test failed: Driver class not found.
Verify the Driver location
Please can I get step by step procedure on how to create this connection.
Thanks.Connect JDeveloper to a MySQL database - YouTube
http://people.cis.ksu.edu/~hankley/d764/tut06/Ross_mySQL/mySQL.htm
Hil &amp; Co IT Solutions: Connecting to MySQL in JDeveloper -
Export All MySQL Databases From CPanel Account Using Actionscript 3 Air Desktop Program
As the title says, and I know there are easier ways, but I need to figure out how to write inside my Adobe Air program a way to retrieve all my MySQL databases and then export all of them to my local computer. So it would export them in the .sql format and I could easily import them if I ever needed to.
I don't know where to even start to try to incorporate this feature.
ThanksHi Jian,
Sorry for the delay.
We're generally a Mac house, so there's only the one Win7 machine that we test on. However we did send the app out for testing, and had similar results on some (but not all) of their Win7 environments.
Where should I send the app? -
Editing MySQL Database from JTable
Hello everyone, I would like to ask your help on how we can edit JTable cells that would be reflected into the database, or how do we change the database via a JTable.
I have the installer of an application which I made with Java SE called FuelStation.exe
My class files are ready for sharing along with its source files.
I have placed it in this location in my website:
http://www.apachevista.com/alphaprojects/runfiles/
It is complete with full details about databases, proposed mysql embed, and so on. Please see the file and notify me at [email protected]
Here is my sample code:
// DisplayQueryResults.java
// Display the contents of the Authors table in the
// Books database.
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.JTable;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.Box;
import javax.swing.JInternalFrame;
import java.util.*; // for the Bundle
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.event.InternalFrameAdapter;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.*; // step 1
import javax.swing.table.TableModel; // step 1
public class DisplayQueryResults extends JInternalFrame implements TableModelListener { // step 2
// JDBC driver, database URL, username and password
ResourceBundle bundle = ResourceBundle.getBundle("Accounting");
final String JDBC_DRIVER = bundle.getString("Driver");
final String DATABASE_URL = bundle.getString("URL");
final String USERNAME = bundle.getString("User");
final String PASSWORD = bundle.getString("Password");
// default query retrieves all data from authors table
//static final String DEFAULT_QUERY = "SELECT authors.lastName, authors.firstName, titles.title, titles.editionNumber FROM titles INNER JOIN (authorISBN INNER JOIN authors ON authorISBN.authorID=authors.authorID) ON titles.isbn=authorISBN.isbn";
final String DEFAULT_QUERY = bundle.getString("Query");
private ResultSetTableModel tableModel;
private JTextArea queryArea;
static final int xOffset = 0, yOffset = 200;
private boolean ALLOW_COLUMN_SELECTION = false;
private boolean ALLOW_ROW_SELECTION = true;
// create ResultSetTableModel and GUI
public DisplayQueryResults() {
super("Sales of the Day",
true, //resizable
true, //closable
true, //maximizable
false);//iconifiable
//...Create the GUI and put it in the window...
//Set the window's location.
setLocation(xOffset, yOffset);
// create ResultSetTableModel and display database table
try {
// create TableModel for results of query SELECT * FROM authors
tableModel = new ResultSetTableModel(JDBC_DRIVER, DATABASE_URL,
USERNAME, PASSWORD, DEFAULT_QUERY);
// set up JTextArea in which user types queries
queryArea = new JTextArea(DEFAULT_QUERY, 1, 100);
queryArea.setWrapStyleWord(true);
queryArea.setLineWrap(true);
JScrollPane scrollPane = new JScrollPane(queryArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
// set up JButton for submitting queries
JButton submitButton = new JButton("Submit Query");
// create Box to manage placement of queryArea and
// submitButton in GUI
Box box = Box.createHorizontalBox();
box.add(scrollPane);
box.add(submitButton);
// create JTable delegate for tableModel
JTable resultTable = new JTable(tableModel);
resultTable.setFillsViewportHeight(true); // Makes the empty space heights white
resultTable.setRowSelectionAllowed(true);
resultTable.getModel().addTableModelListener(this); // step 3
// place GUI components on content pane
add(box, BorderLayout.NORTH);
add(new JScrollPane(resultTable), BorderLayout.CENTER);
// create event listener for submitButton
submitButton.addActionListener(
new ActionListener()
// pass query to table model
public void actionPerformed(ActionEvent event)
// perform a new query
try
tableModel.setQuery(queryArea.getText());
} // end try
catch ( SQLException sqlException)
JOptionPane.showMessageDialog(null,
sqlException.getMessage(), "Database error",
JOptionPane.ERROR_MESSAGE);
// try to recover from invalid user query
// by executing default query
try {
tableModel.setQuery(DEFAULT_QUERY);
queryArea.setText(DEFAULT_QUERY);
} // end try
catch (SQLException sqlException2) {
JOptionPane.showMessageDialog(null,
sqlException2.getMessage(), "Database error",
JOptionPane.ERROR_MESSAGE);
// ensure database connection is closed
tableModel.disconnectFromDatabase();
System.exit(1); // terminate application
} // end inner catch
} // end outer catch
} // end actionPerformed
} // end ActionListener inner class
); // end call to addActionListener
//...Then set the window size or call pack...
setSize(750,300);
setVisible(true); // display window
} // end try
catch (ClassNotFoundException classNotFound) {
JOptionPane.showMessageDialog(null,
"MySQL driver not found", "Driver not found",
JOptionPane.ERROR_MESSAGE);
System.exit(1); // terminate application
} // end catch
catch (SQLException sqlException) {
JOptionPane.showMessageDialog(null, sqlException.getMessage(),
"Database error", JOptionPane.ERROR_MESSAGE);
// ensure database connection is closed
tableModel.disconnectFromDatabase();
System.exit(1); // terminate application
} // end catch
// dispose of window when user quits application (this overrides
// the default of HIDE_ON_CLOSE)
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// ensure database connection is closed when user quits application
addInternalFrameListener(
new InternalFrameAdapter() {
// disconnect from database and exit when window has closed
public void windowClosed(WindowEvent event) {
tableModel.disconnectFromDatabase();
System.exit(0);
} // end method windowClosed
} // end WindowAdapter inner class
); // end call to addWindowListener
} // end DisplayQueryResults constructor
public void tableChanged(TableModelEvent e) { // step 4
int row = e.getFirstRow();
int column = e.getColumn();
TableModel model = (TableModel)e.getSource();
String columnName = model.getColumnName(column);
Object tableModel = model.getValueAt(row, column);
// Do something with the data...
System.out.println(tableModel);
System.out.println("data");
// execute application
public static void main(String args[]) {
new DisplayQueryResults();
} // end main
} // end class DisplayQueryResults
My question is in lines 177-187:
public void tableChanged(TableModelEvent e) { // step 4
int row = e.getFirstRow();
int column = e.getColumn();
TableModel model = (TableModel)e.getSource();
String columnName = model.getColumnName(column);
Object tableModel = model.getValueAt(row, column);
// Do something with the data...
System.out.println(tableModel);
System.out.println("data");
Why is my listener not working or why is it not implemented when I click the cells in the JTable and why is it not reflected into the JTable or into the console?
If this is Flash, Things can be done easily, but this is Java, and I dont know much about this language. I admit that I am new to this -intirely new.
PS:
When you have solved the problem, please notify me with the code that's changed
and please share it to others if you like so.
Best Wishes: Oliver Bob Lagumen
Email: [email protected]
website: www.apachevista.com
Oliver Bob Lagumen
Edited by: Oliverbob on Jan 24, 2008 9:03 PMThis is a follow up on the code I have posted above.
public void tableChanged(TableModelEvent e) { // step 4
int row = e.getFirstRow();
int column = e.getColumn();
TableModel model = (TableModel)e.getSource();
String columnName = model.getColumnName(column);
Object tableModel = model.getValueAt(row, column);
// Do something with the data...
System.out.println(tableModel);
System.out.println("data");
}the tableChanged doesnt get called when I would click the cells. The cells are all editable, but as soon as you edit it and press enter, it snaps back to the old data.
How do we make them editable and how do we notify java that the a cell has changed so that we can send it to the database on that specific column of that specific row?
Thanks in advance
Bob -
Create database link from oracle DB to MySql database using dg4odbc
Hi All
we need to fetch a data of MySQL database from oracle database using dg4odbc connection.
we are getting the below erros when we query select * from dual@myodbc;
ORA-28546: connection initialization failed, probable Net8 admin error
ORA-02063: preceding line from BUGZILLA
OS and database details as follow
1. OS - OEL 5.9 32 bit
2. Database - 11.2.0.1 XE
3. MySQL - 5.5.32
4. ODBC - dg4odbc
5. unixODBC - 2.2.14
6.MySQL Connector - 5.1
kindly help me to get out of this issue.
Thanks in Advance
Regards
Venkatesh VHi All
we need to fetch a data of MySQL database from oracle database using dg4odbc connection.
we are getting the below erros when we query select * from dual@myodbc;
ORA-28546: connection initialization failed, probable Net8 admin error
ORA-02063: preceding line from BUGZILLA
OS and database details as follow
1. OS - OEL 5.9 32 bit
2. Database - 11.2.0.1 XE
3. MySQL - 5.5.32
4. ODBC - dg4odbc
5. unixODBC - 2.2.14
6.MySQL Connector - 5.1
kindly help me to get out of this issue.
Thanks in Advance
Regards
Venkatesh V -
MySQL database connection from Custom JSP
I am trying to connect MySQL database from my custom JSP. I am getting following error which says that the connector JAR (mysql-connector-java-5.1.7) is not in CLASS PATH.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Where should I need to add to get by custom JSP during run time of BPM Studio or Workspace?
I have tried in adding to External resources. But didn't work that way. even I tried adding to "lib" folder in resource view.
My Custom JSP code:_
<%@ page language="java" import="java.sql.*" %>
<html>
<head></head>
<body>
<%
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "aboo";
String driver = "com.mysql.jdbc.Driver";
String userName = "monty";
String password = "some_pass";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
String query = "Select * FROM employeee";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
conn.close();
System.out.println("Disconnected from database");
} catch (Exception ee) {
ee.printStackTrace();
%>
</body>
</html>
Edited by: sideeque on Jul 7, 2009 9:38 AM
Edited by: sideeque on Jul 7, 2009 9:39 AMI got it working by just adding JAR to C:\OraBPMStudioHome\webapps\workspace\lib
-
Unable to login to MySQL Database
Hi ,
I have dumped the MySQL database from production database to the Testing server ........
Then i have created a new user and then try to login to the Web application but it is showing authentication failed error.
Below is the trace of the jboss error ...............
09:06:02,629 INFO [STDOUT] User name gpms password gpms
09:06:02,637 INFO [STDOUT] Connection com.mysql.jdbc.Connection@1cc5d23
09:06:02,637 INFO [STDOUT] SELECT U.ID, U.USER_ID, U.PASSWORD, U.DATE_CREATED, U.CREATED_BY, U.MODIFIED_BY, U.DATE_MODIFIED, U.STATUS, U.MANAGER_ID, U.EMAIL, U.ROLE_ID, R.NAME ROLE_NAME, U.COMPANY_ID, ST.NAME GROUP_NAME, LT.NAME LOCATION_NAME, U.LOCATION_ID, U.GROUP_ID, U.FIRST_NAME, U.LAST_NAME, U.MIDDLE_NAME, U.OFFICE_PHONE_NO, U.OFFICE_PHONE_EXTN, U.EMERGENCY_CONTACT, U.EMERGENCY_PHONE, U.RESIDENT_ADDRESS, U.RESIDENT_PHONE_NO, U.CELL_PHONE_NO, U.PREFERRED_NAME, U.SALES_SUPPORT FROM USER U, ROLES R, STATIC_TYPES ST, STATIC_TYPES LT WHERE ST.ID = U.GROUP_ID AND LT.ID = U.LOCATION_ID AND R.ID = U.ROLE_ID AND UPPER(U.USER_ID) = UPPER('gpms') AND U.PASSWORD=PASSWORD('gpms')
09:06:02,637 INFO [STDOUT] User name isgpms
09:06:02,637 INFO [STDOUT] Password isgpms
09:06:02,642 ERROR [STDERR] java.lang.Exception: Unable to authenticate
09:06:02,643 ERROR [STDERR] at com.gda.common.AuthenticationDAO.authenticate(AuthenticationDAO.java:164)
09:06:02,643 ERROR [STDERR] at com.gda.common.AuthenticationDAO.authenticate(AuthenticationDAO.java:38)
09:06:02,644 ERROR [STDERR] at org.apache.jsp.login_jsp._jspService(login_jsp.java:54)
09:06:02,644 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
09:06:02,644 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
09:06:02,644 ERROR [STDERR] at sSecurityMgrRealm.java:220)
09:06:02,657 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
09:06:02,657 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
09:06:02,658 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
09:06:02,658 ERROR [STDERR] at
09:06:02,660 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)
09:06:02,661 INFO [STDOUT] Error in authentication for gpms
09:06:02,661 INFO [STDOUT] java.lang.Exception: Unable to authenticateNarendra
09:06:02,661 INFO [STDOUT] Unable to authenticate
09:06:02,662 INFO [STDOUT] Authentication failed nullOk, I've tried a lot of stuff. I have modified my application to display error message instead of "Login Failed".
It says: "com.mysql.jdbc.Driver" so like you said the mysql jar is missing.
I have copied the whole mysql-connector-java-5.0.4-bin directory into my application directory. My manifest.mf looks like:
Manifest-Version: 1.0
Class-Path: mysql-connector-java-5.0.4/mysql-connector-java-5.0.4-bin.
jar
Sealed: true
Main-Class: GUI.LoginScreenI have also tried changing names to mysql/mysql.jar.
I have also tried coping just the jar file in the project folder
Class-Path: mysql-connector-java-5.0.4-bin.jar
There is also some .classpath file in the jar and it looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="F:/CurrentDocuments/Fall2006/JavaProjectsTemp/RentItOut/mysql-connector-java-5.0.4/mysql-connector-java-5.0.4-bin.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>I don't know. According to the:
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
You specify classes to include in the Class-Path header field in the manifest file of an applet or application. The Class-Path header takes the following form:
Class-Path: jar1-name jar2-name directory-name/jar3-name
By using the Class-Path header in the manifest, you can avoid having to specify a long -classpath flag when invoking Java to run the your application.
END OF QUOTATION.
Tomorrow I'll try doing it manually under Linux. Maybe Eclipse is doing something. I don't know -
MySQL Database Connection (two databases at the same time)
I have never had to open more than one MySQL database from within the same website before, but I do now. The website I have is designed where all the content comes from within the main database. I am building an Inventory system that I want within it's own database, in the event I would ever need to move the application to another server or something, I don't want this data residing in the main database.
Currently, I open the database connection from within a file called "common.php" that resides in a directory called "lib" that can be accessed from the root directory. Below is the proposed code that would be placed within the "common.php" file:
// Define Database Variables
$dbserver = "127.0.0.1";
$dbuser = array('clevelan_user1', 'clevelan_user2');
$dbpass = array('P@ssw0rd', 'P@ssw0rd2');
$dbname = array('clevelan_database1', 'clevelan_database2');
// Start Session
session_start();
// Connect to Databases
connectdb($dbserver, $dbuser[0], $dbpass[0], $dbname[0]);
connectdb2($dbserver, $dbuser[1], $dbpass[1], $dbname[1]);
// Database 1 Connection
function connectdb($dbserver, $dbuser, $dbpass, $dbname) {
// connects to db
global $connection;
$connection = @mysql_connect($dbserver, $dbuser, $dbpass) or die ("could not connect to server");
$db = @mysql_select_db($dbname, $connection) or die ("could not select databsase");
return $connection;
// Database 2 Connection
function connectdb2($dbserver, $dbuser, $dbpass, $dbname) {
// connects to db
global $connection2;
$connection2 = @mysql_connect($dbserver, $dbuser, $dbpass) or die ("could not connect to server");
$db2 = @mysql_select_db($dbname, $connection2) or die ("could not select databsase");
return $connection2;
//End of Code Within the "common.php"
From within any page of the website, I want to access both connections by placing an include at the top of each page:
include_once("lib/common.php");
Currently, when I run the code above, any page within the website (the home page) provides error messages with regards to database connectivity (the pages are looking for there content from within the second database. It's as if the second database is the only database seen by the website.
I need help figuring out how I can have two MySQL databases open at the same time (the second database will only be open for short periods of time and then closed). But the main database is always open.Create one project using one copy of the exact tables.
create 2 different sessions.xml files each pointing to the same project. Set the login information in the sessions.xml files.
That should work fine.
Peter
Maybe you are looking for
-
Hai every one ! I would like to know how database updates when we run the reversal of payment program. For example we run a payment program and then to reverse it we run some other program . What happens when we run the reversal program ? Payment
-
Instructing clients on domain name transfer
I was wondering what the easiest way is to instruct a client how to transfer their domain name from a previous host to a new one. Do you simply give them the information fom the "Whois" lookup? Do you contact the previous host yourself? What do you d
-
Excute unix script from java.
Hi need to excute unix script from java application. My code is: public class Test public static void main(String args[]) try{ p = Runtime.getRuntime().exec("./qfe0"); //qfe0 is the name of the script. p.waitFor(); catch(Exception e) e.prin
-
Hi, I have just received my new z10. just plugged it in and all im getting is an icon which is showing a usb and computer and a red / orange flashing light in the top corner. What do you think is wrong with this? Many thanks Paul
-
Where do i download jviewsall.jar
Hi where do i get "jviewsall.jar" for downloading? If anyone knows, please help me asap. purna.