mysql5

In a MySQL Trigger, how to get informations on the user sending the request?

℡╲_俬逩灬. 提交于 2019-12-06 07:12:07
问题 I'm on MySQL 5.5, with a trigger, and I want to check if the user can do its request. It's just an exemple, how can I do with a code like this? -- Trigger DDL Statements DELIMITER $$ USE `database`$$ CREATE TRIGGER TBI_TEST BEFORE INSERT ON tb_test FOR EACH ROW BEGIN DECLARE ER_BAD_USER CONDITION FOR SQLSTATE '45000'; IF NEW.host != {{HOW TO KNOW THE HOST PART OF THE CURRENT USER?}} THEN SIGNAL ER_BAD_USER SET MESSAGE_TEXT = 'forbidden', MYSQL_ERRNO = 401; END IF; END$$ 回答1: Ok, i've found

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

陌路散爱 提交于 2019-12-06 02:32:47
问题 Hi When I try to connect to the datasource using JNDI, I am getting this error: [org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) at org.apache.roller.weblogger

How to take mysql dump of selected columns of a table

扶醉桌前 提交于 2019-12-04 18:46:46
问题 I have a requirement in which I have to take mysql dump of just one column of a table. Since that table has too many columns, I don't want to take dump of the full table. I have to get this dump of the table from one server to another. Any idea how I can do this? 回答1: If you would like to take mysql dump including the schema, it can be done by following the below steps: create a temp table: create table temp_table like name_of_the_original_table; duplicating data into temp_table: insert into

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

二次信任 提交于 2019-12-04 07:11:29
Hi When I try to connect to the datasource using JNDI, I am getting this error: [org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) at org.apache.roller.weblogger.business.DatabaseProvider.getConnection(DatabaseProvider.java:179) at org.apache.roller.weblogger

COALESCE two dates returns binary?

和自甴很熟 提交于 2019-12-01 23:41:42
问题 Why does COALESCE(date1,date2) return Blob (binary)? Both columns are of type DATETIME . Here's the complete sql query: SELECT COALESCE( last_modified, date_purchased )As LastModifiedOrPurchased FROM Orders ORDER BY COALESCE( last_modified, date_purchased )DESC LIMIT 1; I'm normally using SQL-Server as rdbms but need to write a synchronization tool. Now i'm trying to select one of two dates. If last_modified is null date_purchased should be returned. But even if there are multiple records

COALESCE two dates returns binary?

耗尽温柔 提交于 2019-12-01 22:38:35
Why does COALESCE(date1,date2) return Blob (binary)? Both columns are of type DATETIME . Here's the complete sql query: SELECT COALESCE( last_modified, date_purchased )As LastModifiedOrPurchased FROM Orders ORDER BY COALESCE( last_modified, date_purchased )DESC LIMIT 1; I'm normally using SQL-Server as rdbms but need to write a synchronization tool. Now i'm trying to select one of two dates. If last_modified is null date_purchased should be returned. But even if there are multiple records where both dates are not null, the query returns just Blob . How to get the correct last date? Edit : on

Stop MySQL tolerating multiple NULLs in a UNIQUE constraint

[亡魂溺海] 提交于 2019-12-01 16:02:24
My SQL schema is CREATE TABLE Foo ( `bar` INT NULL , `name` VARCHAR (59) NOT NULL , UNIQUE ( `name`, `bar` ) ) ENGINE = INNODB; MySQL is allowing the following statement to be repeated, resulting in duplicates. INSERT INTO Foo (`bar`, `name`) VALUES (NULL, 'abc'); despite having UNIQUE ( `name`, `bar` ) Why is this tolerated and how do I stop it? Warning: This answer is outdated. As of MySQL 5.1, BDB is not supported. It depends on MySQL Engine Type . BDB doesn't allow multiple NULL values using UNIQUE but MyISAM and InnoDB allows multiple NULL s even with UNIQUE . In general, depending on the

Stop MySQL tolerating multiple NULLs in a UNIQUE constraint

与世无争的帅哥 提交于 2019-12-01 14:41:16
问题 My SQL schema is CREATE TABLE Foo ( `bar` INT NULL , `name` VARCHAR (59) NOT NULL , UNIQUE ( `name`, `bar` ) ) ENGINE = INNODB; MySQL is allowing the following statement to be repeated, resulting in duplicates. INSERT INTO Foo (`bar`, `name`) VALUES (NULL, 'abc'); despite having UNIQUE ( `name`, `bar` ) Why is this tolerated and how do I stop it? 回答1: Warning: This answer is outdated. As of MySQL 5.1, BDB is not supported. It depends on MySQL Engine Type . BDB doesn't allow multiple NULL

DBunit; confusion over case sensitivity on table/column names

雨燕双飞 提交于 2019-12-01 07:08:25
I'm getting this error when I start up my application Caused by: org.dbunit.dataset.NoSuchColumnException: CLIENT.ID - (Non-uppercase input column: ID) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive I'm not too sure why I'm getting this, since my table/column names all all referenced in upper case(even though the message insists this shouldn't be an issue) My table : mysql> describe CLIENT; +------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+----

apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException: Name [jdbc/proto] is not bound in this Context. Unable to find [jdbc]

瘦欲@ 提交于 2019-12-01 04:37:10
let me describe the environment first: environment: - mac os x (java build 1.6.0_35-b10-428-11M3811) - apache tomcat 7.0.30 - mysql 5.5.27 - tomcat/lib --> mysql-connector-java-5.1.22-bin.jar i've implemented successfully a JDBCRealm and want to switch to a DataSourceRealm because it is recommended for production environments. i use form-based authentication. I did everything described here: http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#DataSourceRealm and here: http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example server.xml <Realm className