Java + Mysql UTF8 Problem

Solved, I forgot to add the encoding when initializing Connection: before was: con = DriverManager.getConnection(“jdbc:mysql:///dbname”, “user”, “pass”); now (working): con = DriverManager.getConnection(“jdbc:mysql:///dbname?useUnicode=true&characterEncoding=utf-8”, “user”, “pass”);

SQL Server Insert Example

To insert a single row of data: INSERT INTO USERS VALUES (1, ‘Mike’, ‘Jones’); To do an insert on specific columns (as opposed to all of them) you must specify the columns you want to update. INSERT INTO USERS (FIRST_NAME, LAST_NAME) VALUES (‘Stephen’, ‘Jiang’); To insert multiple rows of data in SQL Server 2008 or … Read more

Oracle SQL: Use sequence in insert with Select Statement

Assuming that you want to group the data before you generate the key with the sequence, it sounds like you want something like INSERT INTO HISTORICAL_CAR_STATS ( HISTORICAL_CAR_STATS_ID, YEAR, MONTH, MAKE, MODEL, REGION, AVG_MSRP, CNT) SELECT MY_SEQ.nextval, year, month, make, model, region, avg_msrp, cnt FROM (SELECT ‘2010’ year, ’12’ month, ‘ALL’ make, ‘ALL’ model, REGION, … Read more

list extend() to index, inserting list elements not only to the end

Sure, you can use slice indexing: a_list[1:1] = b_list Just to demonstrate the general algorithm, if you were to implement the my_extend function in a hypothetical custom list class, it would look like this: def my_extend(self, other_list, index): self[index:index] = other_list But don’t actually make that a function, just use the slice notation when you … Read more

MyBatis, how to get the auto generated key of an insert? [MySql]

For me it is working like this (mybatis 3.x) .. The id must be set auto increment in mysql table <insert id=”createEmpty” parameterType=”Project” useGeneratedKeys=”true” keyProperty=”project.projectId” keyColumn=”PROJECT_ID”> INSERT INTO PROJECT (TITLE,DESCRIPTION) VALUES (#{title},#{description}) </insert> NOTE keyProperty=”project.projectId” and useGeneratedKeys=”true” my interface is: public int createEmpty(@Param(“project”) Project project, @Param(“title”) String title, @Param(“description”) String description); finally to get the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)