Skip to main content

Posts

Showing posts with the label MySQL

Setting MySQL to Use UTF-8 on MAMP (MySQL 5.5.9, or 5+)

I wanted to setup MySQL to use utf-8 on the MAMP installation on my Mac. I tried the instructions from this article: http://cameronyule.com/2008/07/configuring-mysql-to-use-utf-8/ However, I kept getting error messages that are similar to this one [ERROR] /Applications/MAMP/Library/bin/mysqld: unknown variable 'default-collation=utf8_general_ci' I did some search and realized that several variables are deprecated. Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html Therefore, I added the following lines into /Applications/MAMP/conf/my.cnf [mysql] character-set-server=utf8 [client] character-set-server=utf8 [mysqld] character-set-server=utf8 collation-server=utf8_general_ci init-connect='SET NAMES utf8' I restarted the server and mysql run successfully with relevant variables being set correctly. In the "Variables" tab under phpMyAdmin interface (ex. http://localhost:8888/MAMP/?language=English) character set c...

Install python-mysqldb with lampp on Ubuntu

I try to download python-mysqldb from " http://sourceforge.net/projects/mysql-python/" and run the build/install command: python setup.py build I receive this message: EnvironmentError: mysql_config not found I set mysql_config to "/opt/lampp/bin/mysql_config" (I use lampp) and encounter this error message: cc1: error: unrecognized command line option "-mpentiumpro" cc1: warning: command line option "-felide-constructors" is valid for C++/ObjC++ but not for C cc1: warning: command line option "-fno-rtti" is valid for C++/ObjC++ but not for C error: command 'gcc' failed with exit status 1 so I type sudo apt-get install python-mysqldb and find that I can finally import MySQLdb in python

MySQL :: Connector/J 5.1 -> Database driver you need to connect to MySQL Database Server using Java (JDBC)

MySQL :: Connector/J 5.1 Download “Source and Binaries (zip)” or “Source and Binaries (tar.gz)”. Decompress (unzip) the archive file. Include the .jar file in your library path. (Maybe you have IDE like netbeans or eclipse) Write you code. (Some Sample Code : http://aventurineyao.blogspot.com/2009/12/check-if-there-are-some-records-in.html )

Check if there are some records in ResultSet return from MySQL Database using Java

import java.sql.*; import java.util.*; import java.sql.DriverManager; // return true if some records satisfy the condition, otherwase, false. public Boolean IsExifPhotoIdTimeLongitudeLatitude( String photoId, String time, String longitude, String latitude ){ Connection con = null ; String url = " "; String driver = " "; Statement stmt = null ; String query = " "; // your database table name String targetSheet = " db_table_name "; ResultSet result = null ; Boolean hasRecord = false ; // your query query = " SELECT * FROM ` "+ targetSheet +" ` WHERE photoId=' " + photoId + " ' AND time=' " + time + " ' AND longitude=' " + longitude + " ' AND latitude=' " + latitude + " ' "; try { // connect to mysql database url = " jdbc:mysql://127.0.0.1:3306/database_name "; driver = " com.mysql.jdbc.Driver "; p = new Pro...