Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Transactions With Java And MySQL


I'm trying to port the use of postgresql db to mysql. I'm using
Java and having the following problem - I can't seem to write more
than 1 query per execution. Easier to explain with an example that
worked under postgresql and does not using mysql:

aStatement.executeQuery("BEGIN; DELETE FROM table1; DELETE FROM
table1; DELETE FROM table3; COMMIT;");

If I separate this into 5 different queries it works fine. Any
ideas?




View Complete Forum Thread with Replies

Related Forum Messages:
MySQL Transactions
I found a pretty good(and simplified) article on transactions for the new people to sql out there, however, you will have to have some prior knowledge of howto use commands, And why you would want to implement something of this nature. So, I guess, Intermediates in MySQL, go here.

View Replies !
Can I Do Transactions In MySQL?
I tried to change my sql queries for a program i originally wrote in SQL Server 2000 into MySQL, what irks me is that if i try to run two consecutive insert queries the first query is run but the second one gets ignored.WHY? The code reads thus:

<?php
$sql = "INSERT INTO smsusers (FNAME , LNAME , USERNAME , PASSWORD , TITLE , PHONENO) VALUES ('$thisFNAME' , '$thisLNAME' ,'$thisUSERMAIL' , password('$thisPASSWORD') , '$thisTITLE' , '$thisPHONENO')";

$result = MYSQL_QUERY($sql);
?>

<?php
$sql = "INSERT INTO profilecontents (CONTENTIDID , PROFILEIDNAME , CHECKER ) VALUES ('ACCTINFO' ,'$thisUSERMAIL')";

$result = MYSQL_QUERY($sql);
?>

Perhaps there is sumthin' wrong with ma code????

View Replies !
MySQL And Transactions Entries
I need to insert a new entry in a table but one of its field is an
order field so i use the MAX of current entries in the table.
To lock tables to be sure that 2 persons can't have the same MAX at
the same time, I use transactions.

Nevertheless, How to be sure to get a WRITE lock on this table if my
first statement is a select ?

I'm doing this :

BEGIN;
SELECT MAX(ESSAILOCK_ORDER) AS MAX FROM ESSAILOCK;
INSERT INTO ESSAILOCK (ESSAILOCK_TITRE;ESSAILOCK_ORDER) VALUES
('essai3',MAX);
COMMIT;

If the select is in first, am i just getting a reading lock, which
could allow someone else to insert a new entry with higher order
maybe.



View Replies !
Tracking MySQL Table Transactions
I am trying to understand how I could manage MySQL transactions. I have this database that contains a very important table. Its data changes a lot and contains student grades.
I could have another table where I would keep track of the original table's transactions. I make a backup of this table on a weekly basis and I'm thinking that if I keep track of the sql queries I could recreate the data at any point. So, if a user tels me that he/she overwrote the data, I would restore the portion of the table from the weekly backup, and then go to the transaction table and issue the queries up the point where the data is valid. Is this a good way of restoring data? Is there a better way? Does MySQL have a buil-in system of restoing data?

View Replies !
Using MySQL With Hibernate, Transactions For Selects
I have a general question about transactions around reads. I'm using hibernate and mysql 5.0. What are people's thoughts on wrapping select statements with transactions? I don't believe this will add significant overhead, but is there a disadvantage to not using a txn in this case?

View Replies !
Does MYSQL Support Transactions Like Rollback And Commit Now?
Does MYSQL support transactions like rollback and commit now? How about
stored procedures and subqueries?

View Replies !
Java API To MySQL
--0-413911351-1058468110=:5477
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

I want to know if there is java API to mySQL like its available for C and C++.

View Replies !
MySQL -- Java Vs PHP
Does Java work better than PHP with MySQL? What are pros and cons of using
Java or PHP? I am concerned Java may be slower than PHP with MySQL.
Can someone share the experience or point me to some good white papers or
benchmarks?

View Replies !
MySQL-- Java
I want to make a java-frontend for adding data to a mysql db, have anyone done this?
If so, how?

View Replies !
MySQL + Java
Basically i want a GUI frontend to connect to a database. My experience of this has been visual basic app and access database. The only thing i liked was that to deploy the user only needed the app and the database, deployment was simply packaging the 2 together.Can i make a database using mySQL and deploy it as in the example above? Or does the user need to have a mySQL installed ? Now i all read about databases mySQL/oracle is of a server running the database and the app connecting. However for my app the information will not be updated or changed and therefore i don't need to connect to a server to access the database?

View Replies !
Example Of Java Using Mysql
i have development experience with other languages and rdbms. now i am trying to learn java as well as mysql. can anyone share a simple java app that accesses a mysql table? or point me to any web resources that might have such a working example? i would like to see how one accesses a table stored in a local database.

View Replies !
Mysql And Java
I am using MySQL as a database and am trying to run a sample program to fetch and display data from a table...and dispaly like panel in database
.Please give me the sample code for that .ITs very urgent .I cannot complete my project until ur reply

View Replies !
MySQL Consuming Lots Of Memory During Transactions W/ Many Statements
I am having a problem with MySQL consuming a lot of memory and
eventually throwing an Out of Memory error and restarting itself. The
symptoms are that swap usage continues to rise until some breaking
point. The application is a typical web application w/ 2 web servers
running Apache/Tomcat connecting to a dedicated DB server running only
MySQL.

This seems to occur as a result of running many statements in a single
transaction, both against InnoDB tables and MyISAM tables. In one
case, I'm writing all user actions to an audit table (MyISAM), all from
a single application thread doing approximately 5K inserts (as single
INSERTs on a single connection) every few seconds. In the other, I'm
doing a variety of select/update/insert/delete statements against
InnoDB tables, but again totaling several thousand in one transaction.
Both of these problems occur even when there is relatively low activity
elsewhere on the system. Code:

View Replies !
Mysql Connector Java JAR
I am making a Java Applet connects to mysql database, it works well in
application mode. When I run it in applet mode, obviously the client
running the applet should have the mysql connector file
(mysql-connector-java-3.0.8-stable-bin.jar).

So the question is how to bundle this mysql jar file with my applet jar
file. I've tried to make both 2 files together in the html file:

archive="PCMApplet.jar;mysql-connector-java-3.0.8-stable-bin.jar"

the GUI shows up but the connection call to database is failed:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
It seems to me that the mysql-blah.jar is not being used.

View Replies !
Connecting To MYSQL From JAVA
i need to connect to a MYSQL database from a JSP... so i believe that if i learn how to connect to the MYSQL database through java... i can use the same method to connect through a JSP... anyways my question is does anyone know how to connect to mysql through java.

View Replies !
Connection Between Mysql And Java
I have a big problem, that is that in mysql, I send a Timestate data, and when I try to get it with java, I can't save it into any variable, neither string or Timestamp,

View Replies !
Java To MySQL Connection
I have Data in my MySQL DB. and I wont to use my java class to pull out information from my DB.
my class is this and I wont to add the code in the ***'s
public void getComunicate()
{
url = "jdbc:******:test";

try{
Class.forName("********".Driver");
con = DriverManager.getConnection(url, "MySQL", "1234");
}catch (java.sql.SQLException ex){
System.err.println("SQLException: " + ex.getMessage());

}catch (java.lang.ClassNotFoundException ex){
System.err.println("class not found: " + ex.getMessage());

View Replies !
Communicating With MySQL Through Java
In java is it possible for me to open a socket with a MySQL database and directly send infomation or would I need to use something like php as a buffer.

I know this isn't secure, but the application I am writing does not neet security. I'm just looking for some method to add information to a database. I made a simple .jar file mhich can do what I am looking for but I now I need something which I can upload to a remote webserver.

View Replies !
Mysql-connector-java-3.1.13-bin
I've MYSQL 5 installed and I want to connect to MYSQL using BIE JBOSS . I had put the jar file mysql-connector-java-3.1.13-bin.jar in the deploy/jboss/bie.sar folder and in windows environment I was able to connect to the MYSQL DB. But when I try doing the same in LINUX environment , I get the following error ,

Could not create connection; - nested throwable: (java.sql.SQLException: Cannot connect to MySQL server on <IP>:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.NoRouteToHostException)); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Cannot connect to MySQL server on <IP>:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.NoRouteToHostException)))


View Replies !
How To Ship Mysql Connector Java JAR
I am making a Java Applet connects to mysql database, it works well in
application mode. When I run it in applet mode, obviously the client
running the applet should have the mysql connector file
(mysql-connector-java-3.0.8-stable-bin.jar).

So the question is how to bundle this mysql jar file with my applet jar
file. I've tried to make both 2 files together in the html file:

archive="PCMApplet.jar;mysql-connector-java-3.0.8-stable-bin.jar"

the GUI shows up but the connection call to database is failed:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver

It seems to me that the mysql-blah.jar is not being used.

View Replies !
Ship Mysql Connector Java JAR
I am making a Java Applet connects to mysql database, it works well in
application mode. When I run it in applet mode, obviously the client
running the applet should have the mysql connector file
(mysql-connector-java-3.0.8-stable-bin.jar).

So the question is how to bundle this mysql jar file with my applet jar
file. I've tried to make both 2 files together in the html file:

archive="PCMApplet.jar;mysql-connector-java-3.0.8-stable-bin.jar"

the GUI shows up but the connection call to database is failed:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver

It seems to me that the mysql-blah.jar is not being used.

View Replies !
Connect To Mysql Server Using Java
i am trying to connect to mysql server running on different machine,from a java program. i am successful with mysql3.0. but with mysql5.0 -alpha i am getting the error like this..java.sql.SQLException: Server configuration denies access to data source.

View Replies !
Problem With MySql And Java Under Windows
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import com.mysql.management.driverlaunched.ServerLauncherSocketFactory;

public class ConnectorMXJTestExample {
public static void main(String[] args) throws Exception {
String hostColonPort = "localhost:3306";

String driver = com.mysql.jdbc.Driver.class.getName();
String url = "jdbc:mysql://" + hostColonPort + "/" + "?"
+ "socketFactory="
+ ServerLauncherSocketFactory.class.getName();
String userName = "root";
String password = "";

Class.forName(driver);..................................................

View Replies !
Deleting Mysql Entries In Java
I am asking the user to put in a number and the java prog will look for the corresponding entry and delete it.

so far i have asked the user and stored their choice and now move onto the part of deleting the entry.

i need to call the method for deleting and pass the parameter of the user“s entered number to it.

if im taking the right approach or if "DAO" patterns would be more useful?

View Replies !
Java Mysql Show Table Status
I am using java to retrieve a resultset with "show table status" mysql
command. I am having problem reading the [name] and [engine] column.
In the metadata object it is showing as VARCHAR but when I do
getString() it is returning me the object string (e.g. "[B@1e3e7d2")and
not the actual database value. I am using Mysql 4.1 and jdbc driver
3.1. I tried getB/Clob, getBytes, getCharacterStream() and none of
them is working.

View Replies !
Java In Linux (Redhat 9) To Access MySQL
Using a Java program, I can connect to the test database in MySQL. The
test database is installed using a MySQL utility, and it can be accessed
by any user without supplying a password. The relevant lines in my Java
(Java version 1.4.1) code are:

Connection con = null;
String url = "jdbc:mysql:///test"; // <== no user or password specified
con = DriverManager.getConnection(url);

However, when I try to connect to the accounting database (built as one
follows the Larry Ullman's "MySQL" book), the program fails. I need to
supply a user and a password. The relevant lines are now:

Connection con = null;
String url = "jdbc:mysql:///accounting?user=root&password=pswd"; // <==
con = DriverManager.getConnection(url);

I cannot get a connection. The error message is:

"Invalid authorization specification: Access denied for user:
'root@thorvald' (Using password: YES)"

(thorvald is my machine name.)

I have tried all sorts of variations on the url, trying to access the
accounting database, with no success. I can use the same user/password
of root/pswd within the mysql monitor to access anything I want.

Any ideas?

Again, I am using Linux (Redhat 9) , Java 1.4.1, MySQL 4.0.13, and the
MySQL ConnectorJ 3.0.8 (for Java access to MySQL).

View Replies !
Difficulty Connecting To Mysql Database From Java
Unable to connect to any hosts due to exception:

java.security.AccessControlException: access denied
(java.net.SocketPermission localhost resolve)

What is causing this error? is it a MYSQL or JAVA/JSP Problem, i cant
seem to work this out ?

View Replies !
Connecting Java With MYSQL In Wamp Server
import java.sql.*;

public class Connect
{
public static void main (String[] args)
{
Connection conn = null;

try
{
String userName = "root";
String password = "";
String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
e.printStackTrace();
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}


I have doubt that it is happening since MySQL is in C:wampMySQl.??
This is the output of StackTrace();

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at Connect.main(Connect.java:14)

View Replies !
Connecting To A Remote Mysql Server From A Java Application On Another Machine
i've a java application on a (remote/network) machine and mysql running on my local pc.other users who have access to that remote machine must be able to run that java application which will have to get data/send data to the server(/DB) on my local PC. i was able to run the application when its on my local pC using localhost in the connection string. But, now how do i set the connection string so that the java application accesses the DB (/server) from my local PC?

View Replies !
Way To Use Transactions
I am a mssql programmer now using mysql for a project. Is there a way in mysql to use transactions. meaning i would

begin transaction

run a few sql statemenets

end transaction

with a way to rollback all the statements if any fail. can this be done in mysql?

View Replies !
Why My Transactions Over Lap?
I have 2 application is one windows application and a windows service which will update query on a remote server. My problem here is that I notice that the transaction of my windows service is running the query which are not even part of the program and which are part of my windows application.

081015 18:10:02 92 Quit
93 Connect root@localhost on mpcms5
93 Query SHOW VARIABLES
93 Query SHOW COLLATION
93 Query SET character_set_results=NULL
93 Init DB mpcms5
93 Query Select tblID.lastValue From tblID Where tblID.tableName='tblReceipt'
93 Quit .....

View Replies !
CURRENT_TIMESTAMP And Transactions
MySQL lets CURRENT_TIMESTAMP tick on inside transactions. I'm wondering why? doesn't this violate the atomicity of transactions?

View Replies !
Transactions Tutorial
I'm looking for any online resources/tutorials and such about transactions.
Preferable for MySQL, but others will do.
Other than that, is there any good book about transactions. Again preferable
for MySQL.

View Replies !
Transactions VS Fulltext
I've got a bit of a problems.
I'm using transactions to insert information into a couple of tables. Its an "all or nothing" procedure, and data integrety is important.
However, I've come across a stumbling block. The information which is being inserted needs to be fully searchable with relevance. Which means fulltext indexing. Which I can't use on InnoDB tables.

View Replies !
Transactions & Commit
if you call a BEGIN and then you process some data, am i right in saying that you must call a COMMIT to actually have any effect on the database?

View Replies !
Transactions Supported
Looking at the docs, it says 3.23 supported transactions through using InnoDB tables. A person Im building a website for has already chosen a host that is using this version of MySQL. We may or may not need transactions, but Im just getting ready.

Here is an article talking about their use with MySQL, but it states the example requires ver 4
http://www.devarticles.com/c/a/MySQ...QL-4.0-and-PHP/

View Replies !
Transactions Not Supported
Transactions not supported by database at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI.pm line 672.

I was told that I need to recompile MySQL libmysqlclient as it doesn't look like it supports transactions. I tried to recompile with ./configure --without-server and replaced libmysqlclient.so.15.0.0 and libmysqlclient.a in the appropriate directories. I am still having the same problem.

View Replies !
Transactions & Locking
I am developing a multi-user database and I have a few questions about this.

Will I need to use transactions or locking for single simple SQL statements?

Or is MySQL smart enough to know not to let two people edit the same record at the same time?

View Replies !
Nested Transactions
If a transaction is started in a stored procedure 'A' that calls stored procedure 'B' which has its own start transaction... commit statements, can 'A' rollback and undo the changes made by 'B' if it decides not to commit any longer?

View Replies !
Auditing Transactions
With regard to auditing transactions :

- Does MySQL have a table of users similar to Oracle's "ALL_USERS", allowing me to insert a user_id (rather than the full user_name string) into an audit column such as "last_updated_by" or "created_by" ?

- Is there a function similar to Oracle's SYSDATE ?

View Replies !
Set AutoIncrement And Transactions
in MySQL how is it possible to manage transactions and set manually auto_increment start value? With InnoDB Tables it's not possible!

View Replies !
InnoDB And Transactions
I have a problem with InnoDB and Transactions. I have a WebApplication running ColdFusion MX 6.1 and MySQL 4.0.17.
I have many changes to database and all changes which belongs together a put in a transaction, because when errors occours, mysql rolls back the changes made. This works great.
But now I have the following problem. When the user submits the form two times, both transaction are parallel. For example the first step is to select a number, and at the end of the transaction I insert a new line with "number+1". Normally it is not possible to get the same number in two lines. But when the user submits the form twice quickly and the first transaction is not ready yet, both transactions put a line with the same number. How can I make Mysql to wait with the second transaction on the same table until the first transaction is ready? I tried with "SELECT FOR UPDATE" and with the transaction-parameter "serializable", but both don`t work

View Replies !
Using Transactions With InnoDB
Right now I am experiencing with transactions in MySQL using the InnoDB engine.
I found a really great article which includes all about transactions:
http://dev.mysql.com/books/mysqlpres...rial/ch10.html

However, I still got a question and I couldn't find the answer exactly in this article.
A simple example:

UPDATE users SET money = money - 1000 WHERE id = 1 ;
UPDATE users SET money = money + 1000 WHERE id = 2 ;
I just want both queries executed OR both not executed, so I should use a transaction.
I thought the following would give me the right result, but it is not exactly what I want:

START TRANSACTION ;
UPDATE users SET money = money - 1000 WHERE id = 1 ;
UPDATE users SET money = money + 1000 WHERE id = 2 ;
COMMIT ;
If user 1 doesn't have 1000 dollar anymore, both queries shouldn't be executed.
The same for when the field name in the first query is wrong spelled or doesn't exist, both queries shouldn't be executed.

I read something about ROLLBACK in the mysql article on the mysql.com website and I think I can solve my problem with this one, but I don't know exactly how to use this.

The example in the article says:

START TRANSACTION ;
UPDATE users SET money = money - 1000 WHERE id = 1 ;
UPDATE users SET money = money + 1000 WHERE id = 2 ;
SELECT money FROM users WHERE id = 1 ;
ROLLBACK ;
But this one doesn't work for me. The ROLLBACK will always be executed, even when the user got enough money.

View Replies !
How To Learn Transactions
i have a problem to study transaction log in mysql, please any bady have example aplication to help me ?

View Replies !
Transactions - Rollback
Is it necessary to call 'ROLLBACK' statement if one of your queries fails? Or is it sufficient just NOT to call 'COMMIT'.

Seems to be working both ways for me.

View Replies !
Are Transactions Faster?
I know that database engines that support transactions tend to be slower than engines without support for transactions (e.g. innodb and myisam).

But are transactions faster than separate queries?

Example:

I need to run 15 edit queries.

Will it be faster if I just run them one by one or if I wrap them inside a transaction? My understanding of transactions is that the database gets queried only once with all queries inside the transaction and then it runs it one by one. So it should be faster or no?

View Replies !
MyIsan Will Support Transactions?
I would like to know if mysql 5.0 myisan type will support transactions?

View Replies !
Stored Procedures &amp; Transactions
I wonder whether it is possible to use transactions like this:

CREATE PROCEDURE testproc

BEGIN
START TRANSACTION;
CALL another_proc();
COMMIT;

END;

Or is there anything I need to take care of?

The reason I am asking is, I have a project with lots of SPs and I need to add transactions now.

View Replies !
Using Transactions With The MyISAM Engine
As far as I know MyISAM doesn't support transactions so I was expecting that using start transaction and commit in an sproc should have no effect if the tables involved are MyISAM but actually this is not the case. Well, although you can't roll back with MyISAM, using start transaction and commit speed up write operations if you have more than one writing operation in the same sproc.

So even though start transaction and commit are not supported for the MyISAM engine, is it ok to use them for the sake of performance? Are there any side effects of such approach?

View Replies !
Transactions In Stored Procedures
I am handling transactions in stored procedures. Now, if due to some error in the middle of the stored procedure, control comes out of the stored procedure. But, my transaction that was started in the beginning of the procedure has not ended. Therefore, it is going to effect my application. Please tell me what should be done.

Whether some error handling is the solution just like in java, .net languages.

Or what else?

View Replies !
Group Transactions By Week
I am having problems finding how to group transactions by week.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved