mysql

How to connect to MySQL from a JSP?

I have installed MySQL Server 4.1 and mysql-connector-java-3.0.17-ga. I have the JSP code just to establish a connection. When I try to execute it, it throws java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. Which file am I missing and where should I place it? Thanks in advance. ...

Search for all occurrences of a string in a mysql database.

I'm trying to figure out how to locate all occurrences of a url in a database. I want to search all tables and all fields. But I have no idea where to start or if it's even possible. ...

MySQL UPDATE and SELECT in one pass

I have a MySQL table of tasks to perform, each row having parameters for a single task. There are many worker apps (possibly on different machines), performing tasks in a loop. The apps access the database using MySQL's native C APIs. In order to own a task, an app does something like that: Generate a globally-unique id (for simplic...

How do I use interact with MySQL using Java ?

I'm assuming I need to use Connector\J and JDBC to achieve this, but I can't seem to 'install' Connector\J using the CLASSPATH thing. How do I do that ? I use the IntelliJ IDE if thats relevant. I'm looking for a way to talk to a mysql database and execute and print out a few basic queries but I'm not getting anywhere because I can't e...

Simple Mysql table join problem

I'm designing a website to teach myself how to use table joins in mysql and have got stuck pretty early on. (The numbers are Wii friend codes, if that helps you make sense of this!) I have 3 tables: users: id, firstname, surname games: id, title numbers: number, users_id, game_id The number is a unique code that belongs to the...

Getting return values from a MySQL stored procedure in Python, using MySQLdb

I've got a stored procedure in a MySQL database that simply updates a date column and returns the previous date. If I call this stored procedure from the MySQL client, it works fine, but when I try to call the stored procedure from Python using MySQLdb I can't seem to get it to give me the return value. Here's the code to the stored pr...

Is there a speed difference in MySQL operations?

I was discussing speed of MySQL statements and someone asked me: Between SELECT, INSERT, UPDATE, and DELETE, which is faster and why? I didn't know the answer. Does anyone know if one is faster than the other, and if so, why? Or are they all generally the same speed? ...

How to put IF statement in MySQL query

Hey all! I have a query that is simply selecting from 3 tables. select from the comments table for all comments on an article select from UserID table to find what kind of user it is IF the user is one type, search one table...ELSE search another table for the final info. How would I go about this? I'm a little new at MySQL stuff, s...

Triggers and stored proc in MySQL

I used MSSQL stored procedures and triggers for a while; MySQL is getting me absolutely crazy about how to write even the simpler procedure. Why I get a syntax error in this so stuoid trigger? CREATE TRIGGER set_prio_default BEFORE INSERT ON categories FOR EACH ROW BEGIN set @my_prio := 1; SET new.prio := @my_prio; END In facts...

In MySQL what does "Overhead" mean, what is bad about it, and how to fix it?

simple question, but its been nagging me for a while now.... what is "overhead" in MySQL, and should i be worried? does clicking "optimize table" fix it for real? ...

How do I migrate a populated mySQL database from dev to a shared host?

The title pretty much says it all, but to elaborate: If I build a mySQL database on my local dev machine, populate it with data, and subsequently want to migrate the database to a shared host (in this case, Siteground,) how do I do so in a way that keeps structure and data intact? In this case, I don't have file access to the database s...

Ruby On Rails is slow... ?

I'm writing a web application to monitor a furniture factory production flow. It has thousand of data to handle. So far, I run RoR on Mongrel + MySQL and it's really really slow (2-4min for some views). When I look at RoR logs, it seems that database queries aren't slow (0-10ms). Is RoR slow when it converts database data to object ? Is...

Use of mysql_unbuffered_query in Zend Frame Work, is it supported?

I need to run a query which will retrieve a huge amount of records. This means I can't use the ZF wrappers for mysqli, which deep below the hood uses mysqli-store-result. So, is there a wrapper in ZF for using the mysqli mysqli-use-result link text, which will return an Iterator/record-set/resource and not the array with all the results ...

What is the best way to setup permissions for web site users?

I'm working on a web site where each user can have multiple roles/permissions such as basic logging in, ordering products, administrating other users, and so on. On top of this, there are stores, and each store can have multiple users administrating it. Each store also has it's own set of permissions. I've confused myself and am not sur...

What's wrong with this query? EXPLAIN looks fine to me...

I'm going through an application and trying to optimize some queries and I'm really struggling with a few of them. Here's an example: SELECT `Item` . * , `Source` . * , `Keyword` . * , `Author` . * FROM `items` AS `Item` JOIN `sources` AS `Source` ON ( `Item`.`source_id` = `Source`.`id` ) JOIN `authors` AS `Author` ON ( `Item`.`author...

What is the complexity of finding median and doing counts in MySQL?

I would like to know what the complexity of the following two operations are. The first case is a count where I order by a column that I have an index on and ask for the count of all values below or above a certain number like this: SELECT count(*) FROM tbl WHERE col1 > 10 ORDER BY col1; The other case is concerning a median operation...

How can I view live MySQL queries?

Hey all, I am just wondering if its possible to trace MySQL queries on my linux server as they happen? For example I'd love to set up some sort of listener, then request a web page and view all of the queries the engine executed, or just view all of the queries being run on a production server. Are there tools to do this? Thank you, ...

script to tell me who, and how many users, are online

In my research to find a way to make PHP tell me how many people are 'online' on my site I've discovered that there are ways to 'estimate' this. I've chosen to log everything that happens on the site, also for error-management sake, but now i'm stuck at writing my SQL query. Basicly I have a database with 'IP', 'userid' and 'datetime'...

General mysql freeze question

Our mysql server is behaving strangely - doing a heavy query on one table will pretty much lock it, no other query will be responded to, even if it's a trivial one on completely unrelated table (like SELECT by primary key, INSERT, or even EXPLAIN) - it will just wait for the heavy one to finish. I'm really out of ideas what could be caus...

SQL problem, LEFT JOIN [..] IN()

This small SQL error is bugging me. It doesn't seem to be a problem with the query, just the scope(?), examples work best: SELECT ocp.*, oc.*, GROUP_CONCAT( u.username SEPARATOR ', ') AS `memjoined` FROM gangs_ocs_process ocp, gangs_ocs oc LEFT JOIN users u ON u.userid IN ( ocp.membersin ) WHERE ocp.ocid =1 AND ocp.gangid =1 AND oc.oc_n...