Skip to main content

Posts

Showing posts with the label Mysql

MySql Timediff and JDBC (ConnectorJ) - Bad format for Time 'hhh:mm:ss' in column x

MySQL Types to Java Types for ResultSet.getObject(). MySQL Type Name Return value of GetColumnClassName Retur TIME TIME java.sql.Time http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-type-conversions.html ResultSet.getTime() will fail with an SQLException: "Bad format for Time 'hhh:mm:ss' in column x" http://bugs.mysql.com/bug.php?id=11154 Surprisingly (Shockingly) ResultSet.getString() was also throwing the same exception "Bad format for Time". http://forums.sun.com/thread.jspa?threadID=5149261

MySQL :: tinyInt1isBit

One can enter values apart from 0 and 1 (say 2,3,?100) in a field with tinyint(1) type in MySql. MySql doesn?t complain. Now if you want to read inserted data using PHP it will return value as it is, however this will not work with Java. Java will throw an exception while reading same MySql data. Java treats tinyint(1) as Boolean and returns only true or false. Two solution either we can make our column tinyint(something > 1), or can add the connection property 'tinyInt1isBit=false' to our JDBC URL. Adding connection property 'tinyInt1isBit=false' to JDBC URL is risky since it will affect entire database data while reading the same using Java. Refer : http://forums.mysql.com/read.php?39,10652,10669#msg-10669

Java Web application and UTF-8

Java and UTF-8 Generally we can rely on Java as long as source strings are properly encoded. Please refer link: http://java.sun.com/docs/books/tutorial/i18n/text/convertintro.html, http://java.sun.com/javase/technologies/core/basic/intl/faq.jsp Tomcat and UTF-8 JSP pages must include the header: Update the file $CATALINA_HOME/conf/server.xml : add attribute URIEncoding="UTF-8" in Connector tag Add filter as suggested in the link : http://wiki.apache.org/tomcat/Tomcat/UTF-8 Tomcat UTF-8 Problem with request.getParameter(), http://answers.google.com/answers/threadview?id=580467 useBodyEncodingForURI : http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html MySql and UTF-8 We need our databases and tables to be in utf8 character set : ALTER tables with an SQL statement like - ALTER DATABASE db_name CHARACTER SET utf8 COLLATE utf8_general_ci; Start mysql-demon using option "--character-set-server=utf8" : mysqld ócharacter-set-server=utf8 May be use...

Securing MySQL (Java / Php Developers)

This Article would be useful to the people those who are using MySQL on a server connected to the Internet and hosted a web application (Developed using Java or/and PHP) on same server. This would also allow users to avoid a common security mistakes and Java developer to understand an issue related to UNIX socket. Usually MySQL uses port 3306 by default. This port should not be accessible from un-trusted hosts and should be closed, unless you really have a good reason to keep it open . This can be done on Server’s firewall or router, however M ySql provides its own security options like 1. skip-networking 2. bind-address 1. skip_networking This option was added in MySQL 3.22.23 and is recommended for systems where only local clients are allowed.To enable this option, put “skip-networking” in the mysql configuration file (/etc/mysql/my.conf). If this option is ON the server allows only local (non-TCP/IP) connections. Any clients (even clients running on the same host) using the remote ...