Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i have stumbled on an error which i have spend 3hours trying to fix.
i'm trying to save some data from my server onto my mysql db on my webhost.
i do already have my vps ip set in my remote sql thing.
But i'm stumbling into a mysql syntax error.
Would be very grateful if you can help me,
thanks in advance!
my console:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your S
QL syntax; check the manual that corresponds to your MySQL server version for th
e right syntax to use near '' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3243)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1343)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1260)
at org.dementhium.mysql.hiscores.query(hiscores.java:53)
at org.dementhium.mysql.hiscores.saveHighScore(hiscores.java:80)
my java file:
package org.dementhium.mysql;
import java.sql.SQLException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.dementhium.model.player.Player;
import org.dementhium.model.player.Skills;
import org.dementhium.model.player.Skills;
import org.dementhium.mysql.DatabaseManager;
/**
*
* #author 'Mystic Flow <Steven#rune-server.org>
*/
#SuppressWarnings("unused")
public class hiscores extends Thread {
public static final String[] SKILLS = {"Attack", "Defence",
"Strength", "Constitution", "Ranged", "Prayer", "Magic", "Cooking",
"Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting",
"Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer",
"Farming", "Runecrafting", "Hunter", "Construction", "Summoning",
"Dungeoneering"
};
public static Connection con = null;
public static Statement stmt;
public static boolean connectionMade;
public static void createConnection() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://slash-scape.org/slash756_highsco","slash756_highsco","");
stmt = con.createStatement();
System.out.println("Highscores updated for ");
} catch (Exception e) {
e.printStackTrace();
}
}
public static ResultSet query(String s) throws SQLException {
try {
if (s.toLowerCase().startsWith("select")) {
ResultSet rs = stmt.executeQuery(s);
rs.updateRow();
return rs;
} else {
stmt.executeUpdate(s);
}
return null;
} catch (Exception e) {
destroyConnection();
createConnection();
e.printStackTrace();
System.out.println("Highscores updated for,hgjhkhkjhkj ");
}
return null;
}
public static void destroyConnection() {
try {
stmt.close();
con.close();
connectionMade = false;
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean saveHighScore(Player player) {
try {
//query("DELETE FROM `highscores` WHERE username = '"+player.getUsername()+"';");
//query("DELETE FROM `highscores` WHERE username = '"+player.getUsername()+"';");
System.out.println("Highscores updated for,hgjhkhkjhkj ");
query("INSERT INTO `highscores` (`username`,`attack_xp`,`defence_xp`,`strength_xp`,`hitpoints_xp`,`ranged_xp`,`prayer_xp`,`magic_xp`,`cooking_xp`,`woodcutting_xp`,`fletching_xp`,`fishing_xp`,`firemaking_xp`,`crafting_xp`,`smithing_xp`,`mining_xp`,`herblore_xp`,`agility_xp`,`thieving_xp`,`slayer_xp`,`farming_xp`,`runecraft_xp`,`hunter_xp`,`construction_xp`,`summoning_xp`,`dungeoneering_xp`,`overall_xp`,`rights`) VALUES ("+player.getUsername()+","+player.getSkills().getXp(0)+","+player.getSkills().getXp(1)+","+player.getSkills().getXp(2)+","+player.getSkills().getXp(3)+","+player.getSkills().getXp(4)+","+player.getSkills().getXp(5)+","+player.getSkills().getXp(6)+","+player.getSkills().getXp(7)+","+player.getSkills().getXp(8)+","+player.getSkills().getXp(9)+","+player.getSkills().getXp(10)+","+player.getSkills().getXp(11)+","+player.getSkills().getXp(12)+","+player.getSkills().getXp(13)+","+player.getSkills().getXp(14)+","+player.getSkills().getXp(15)+","+player.getSkills().getXp(16)+","+player.getSkills().getXp(17)+","+player.getSkills().getXp(18)+","+player.getSkills().getXp(19)+","+player.getSkills().getXp(20)+","+player.getSkills().getXp(21)+","+player.getSkills().getXp(22)+","+player.getSkills().getXp(23)+","+player.getSkills().getXp(24)+","+((player.getSkills().getXp(0)) + (player.getSkills().getXp(1)) + (player.getSkills().getXp(2)) + (player.getSkills().getXp(3)) + (player.getSkills().getXp(4)) + (player.getSkills().getXp(5)) + (player.getSkills().getXp(6)) + (player.getSkills().getXp(7)) + (player.getSkills().getXp(8)) + (player.getSkills().getXp(9)) + (player.getSkills().getXp(10)) + (player.getSkills().getXp(11)) + (player.getSkills().getXp(12)) + (player.getSkills().getXp(13)) + (player.getSkills().getXp(14)) + (player.getSkills().getXp(15)) + (player.getSkills().getXp(16)) + (player.getSkills().getXp(17)) + (player.getSkills().getXp(18)) + (player.getSkills().getXp(19)) + (player.getSkills().getXp(20)) + (player.getSkills().getXp(21)) + (player.getSkills().getXp(22)) + (player.getSkills().getXp(23)) + (player.getSkills().getXp(24)))+","+player.getRights()+";");
//query("INSERT INTO `skillsoverall` (`playerName`,`lvl`,`xp`, `prestige`) VALUES ('"+player.getUsername()+"',"+(player.getSkills().getLevel(0) + player.getSkills().getLevel(1) + player.getSkills().getLevel(2) + player.getSkills().getLevel(3) + player.getSkills().getLevel(4) + player.getSkills().getLevel(5) + player.getSkills().getLevel(24) + player.getSkills().getLevel(6) + player.getSkills().getLevel(7) + player.getSkills().getLevel(8) + player.getSkills().getLevel(9) + player.getSkills().getLevel(10) + player.getSkills().getLevel(11) + player.getSkills().getLevel(12) + player.getSkills().getLevel(13) + player.getSkills().getLevel(14) + player.getSkills().getLevel(15) + player.getSkills().getLevel(16) + player.getSkills().getLevel(17) + player.getSkills().getLevel(18) + player.getSkills().getLevel(19) + player.getSkills().getLevel(20) + player.getSkills().getLevel(21) + player.getSkills().getLevel(22) + player.getSkills().getLevel(23))+" ,"+((player.getSkills().getXp(0)) + (player.getSkills().getXp(1)) + (player.getSkills().getXp(2)) + (player.getSkills().getXp(3)) + (player.getSkills().getXp(4)) + (player.getSkills().getXp(5)) + (player.getSkills().getXp(6)) + (player.getSkills().getXp(7)) + (player.getSkills().getXp(8)) + (player.getSkills().getXp(9)) + (player.getSkills().getXp(10)) + (player.getSkills().getXp(11)) + (player.getSkills().getXp(12)) + (player.getSkills().getXp(13)) + (player.getSkills().getXp(14)) + (player.getSkills().getXp(15)) + (player.getSkills().getXp(16)) + (player.getSkills().getXp(17)) + (player.getSkills().getXp(18)) + (player.getSkills().getXp(19)) + (player.getSkills().getXp(20)) + (player.getSkills().getXp(21)) + (player.getSkills().getXp(22)) + (player.getSkills().getXp(23)) + (player.getSkills().getXp(24)))+";");
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}
my MySQL database query:
CREATE TABLE IF NOT EXISTS `highscores` (
`id` int(11) NOT NULL primary key AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`rights` int(1) NOT NULL DEFAULT '0',
`overall_xp` bigint(20) NOT NULL,
`attack_xp` int(11) NOT NULL,
`defence_xp` int(11) NOT NULL,
`strength_xp` int(11) NOT NULL,
`constitution_xp` int(11) NOT NULL,
`ranged_xp` int(11) NOT NULL,
`prayer_xp` int(11) NOT NULL,
`magic_xp` int(11) NOT NULL,
`cooking_xp` int(11) NOT NULL,
`woodcutting_xp` int(11) NOT NULL,
`fletching_xp` int(11) NOT NULL,
`fishing_xp` int(11) NOT NULL,
`firemaking_xp` int(11) NOT NULL,
`crafting_xp` int(11) NOT NULL,
`smithing_xp` int(11) NOT NULL,
`mining_xp` int(11) NOT NULL,
`herblore_xp` int(11) NOT NULL,
`agility_xp` int(11) NOT NULL,
`thieving_xp` int(11) NOT NULL,
`slayer_xp` int(11) NOT NULL,
`farming_xp` int(11) NOT NULL,
`runecrafting_xp` int(11) NOT NULL,
`hunter_xp` int(11) NOT NULL,
`construction_xp` int(11) NOT NULL,
`summoning_xp` int(11) NOT NULL,
`dungeoneering_xp` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I think you are constructing your query incorrectly by not quoting Strings. This is only going to be compounded if your Strings have additional quotes in them!
To get around this, use PreparedStatement. Not only is it simpler, it's safer and helps prevent SQL Injection attacks.
Basic example:
final static String INSERT_QUERY = "INSERT INTO highscores (username,attack_xp,defence_xp) values(?,?,?)"; // Etc...
PreparedStatement ps = connection.prepareStatement(INSERT_QUERY);
ps.setString(1, player.getUsername());
ps.setInt(2, player.getAttackXp());
ps.setInt(3, player.getDefenseXp());
// etc.
ps.execute();
Your query is incorrect, one of the mistake is varchar should be wrapped with ' you are not doing it, also it is messy and vulnerable so use PreparedStatement instead
Related
so this is my table
CREATE TABLE "client" (
"id" INTEGER,
"name" TEXT COLLATE NOCASE,
"surname" TEXT COLLATE NOCASE,
"number" TEXT UNIQUE COLLATE NOCASE,
"car_brand" TEXT,
"modele" TEXT,
"phone_nbr" TEXT,
PRIMARY KEY("id" AUTOINCREMENT));
when im adding a new statment from my java application i can add only one time NULL to the column number but i can add many nulls from the db browser
this is the code that i use
String number = tf_number.getText();
if(tf_number.getText().trim().isEmpty())
number = null;
String name = tf_name.getText();
String surname = tf_surname.getText();
String phoneNbr = tf_phoneNbr.getText();
String car_brand = tf_brand.getText();
String modele = tf_modele.getText();
Client c = new Client(name, surname, number, car_brand, modele, phoneNbr);
ClientCRUD pcd = new ClientCRUD();
pcd.addClient(p);
and this is the sql error
[SQLITE_CONSTRAINT_UNIQUE] A UNIQUE constraint failed (UNIQUE constraint failed: client.number)
this is the addClient() fonction
public void addClient(Client t) {
try {
String requete = "INSERT INTO CLIENT(name,surname,number,car_brand,MODELE,phone_nbr)"
+ "VALUES ('"+t.getClientName()+"','"+t.getClientSurname()+"','"+t.getNumber()+"',"
+ "'"+t.getCarBrand()+"','"+t.getModele()+"','"+t.getPhone()+"')";
Statement st = MyConnection.getInstance().getCnx()
.createStatement();
st.executeUpdate(requete);
System.out.println("Client added");
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
any solution ?
public void save(Person person) {
String query = "INSERT INTO person_info (" +
" name_p, " +
" age, " +
" address, " +
" email " +
")" +
"VALUES(?, ?, ?, ?)";
try(Connection connection = dbConnection.getConnection()) {
PreparedStatement prepStatement = connection.prepareStatement(query);
prepStatement.setString(1, person.getName());
prepStatement.setInt(2, person.getAge());
prepStatement.setString(3, person.getAddress());
prepStatement.setString(4, null);
prepStatement.execute();
}
catch (SQLException e){
e.printStackTrace();
}
}
##This will solve your problem
You code inserts the string "null" and not a real null like your browser do.
So there can be only 1 string with value "null" in that unique column.
You can use preparedStatement with parameters instead of the statement you use.
E.g:
PreparedStatement preparedStatement = connection.prepareStatement(sql))
This answers how to insert null using prepared statement: Insert null using prepared statement
And your sql string for the query should have the parameters.
See more about prepared statements: Prepared Statements Tutorial
I am creating a database that keeps track of Spiderman comic books. I am getting a SQLExecption at line 28:
stmt.executeUpdate(createstring);"
So I assume there is something wrong with the syntax of my SQL that is in the createstring but nothing jumps out at me.
Below is code
import java.sql.*;
import javax.swing.*;
public class SpidermanDatabase {
public static void main(String[] args)
{
String url = "jdbc:ucanaccess://c:/users/jeff/comics.accdb";
Connection con;
String createstring;
createstring = "CREATE TABLE Spider-Man (" +
"ComicName varchar(40), " +
"IssueDate varchar(40), " +
"IssueName varchar(40), " +
"MintCond varchar(40), " +
"IssueValue double(2,2), " +
"IssueNum int)";
Statement stmt;
try
{
con = DriverManager.getConnection(url, "", "");
stmt = con.createStatement();
stmt.executeUpdate(createstring);
JOptionPane.showMessageDialog(null, "Spider-Man table created", "SQL Statement Confirmation",
JOptionPane.INFORMATION_MESSAGE);
stmt.close();
con.close();
System.exit(0);
}
catch(SQLException ex)
{
System.out.println("SQLException");
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
}
Image attached is full error message
It appears to me that you are using Microsoft Access database. It also appears that you are using ucanaccess JDBC driver to connect to that database.
Your problem is that you are using an illegal character in the name of the table that you are trying to create. According to Microsoft documentation, identifiers, such as database table names, cannot contain a dash (-) (also known as a hyphen) – unless you enclose the identifier in either square brackets, i.e. [], or quotation marks.
Hence you should change the SQL create table string to the following:
createstring = "CREATE TABLE [Spider-Man] (" +
"ComicName varchar(40), " +
"IssueDate varchar(40), " +
"IssueName varchar(40), " +
"MintCond varchar(40), " +
"IssueValue double, " +
"IssueNum int)";
Also note that the double data type cannot have scale and precision qualifiers. Hence I also removed the (2,2) part from the data type for column IssueValue.
Remember that after this you must always write [Spider-Man] (or "Spider-Man") as the table name in all SQL statements. Alternatively, you could replace the dash with and underscore (_) which is a legal character in an identifier and thus do away with the need for square brackets (or quotation marks), i.e. name the table Spider_Man.
EDIT
Although the above CREATE TABLE statement is valid SQL, it appears that ucanaccess JDBC driver cannot handle it. The only way I got it to work was to replace the dash with an underscore.
Here is my java code for creating the database table Spider_Man.
(Note that the below code uses try-with-resources.)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcTst0 {
public static void main(String[] args) {
String url = "jdbc:ucanaccess://C:/users/jeff/comics.accdb";
String createstring = "CREATE TABLE Spider_Man (" +
"ComicName varchar(40), " +
"IssueDate varchar(40), " +
"IssueName varchar(40), " +
"MintCond varchar(40), " +
"IssueValue double, " +
"IssueNum int)";
try (Connection con = DriverManager.getConnection(url, "", "");
Statement stmt = con.createStatement()) {
stmt.executeUpdate(createstring);
System.out.println("Spider_Man table created");
}
catch (SQLException xSql) {
xSql.printStackTrace();
}
}
}
I am facing a strange problem when I try to update a certain row in my table.
I am using the Connection class from java.sql library. Following is my table script:
CREATE TABLE `crd_web_request` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` varchar(30) NOT NULL,
`trn_notes` varchar(200) DEFAULT NULL,
`trn_date` date NOT NULL,
`amount` double(20,3) DEFAULT '0.000',
`other_amount` double(20,3) DEFAULT '0.000',
`card_fees` double(20,3) DEFAULT '0.000',
`shipping_fees` double(20,3) DEFAULT '0.000',
`sys_trtype_id` int(11) DEFAULT NULL,
`crd_agent_mast_id` int(11) DEFAULT '0',
`sys_phase_id` int(11) DEFAULT '0',
`sys_user_id` int(11) DEFAULT NULL,
`cust_aname` varchar(250) DEFAULT NULL,
`cust_ename` varchar(250) DEFAULT NULL,
`sys_nationality_id` int(11) DEFAULT NULL,
`passport_id` varchar(45) DEFAULT NULL,
`sys_doc_type_id` int(11) DEFAULT NULL,
`cust_doc_id` varchar(45) DEFAULT NULL,
`cust_email` varchar(250) DEFAULT NULL,
`cust_address` varchar(250) DEFAULT NULL,
`cust_tel` varchar(30) DEFAULT NULL,
`card_holder_name` varchar(400) DEFAULT NULL,
`status` int(1) NOT NULL DEFAULT '0',
`cardType_ID` int(20) DEFAULT NULL,
`sys_org` int(2) DEFAULT NULL,
PRIMARY KEY (`id`,`order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=237 DEFAULT CHARSET=utf8;
and following is my java code to update the table:
Statement stmt = null;
String query = "UPDATE smcpp16.crd_web_request SET status = 1 WHERE order_id = '" + orderId + "'";
try {
stmt = conn.createStatement();
System.out.println(query);
stmt.execute(query);
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
I can it figure out why this is happening. Every time when executing the update statement, the table inserts a new record with the same values of the updated row. Can you please help?
I removed the closing of the connection from this code and the duplication is not happening any more.
I just removed:
conn.close();
It is a practice to close the connection in the finally block, something like this :
try{
// update data
}
catch{
//catch exception
}
finally{
//close connection
conn.close();
}
Let me know if this helps.
I've been trying to insert a date into the Oracle database using JDBC, SimpleDateFormat API.
When I passed the date as "2016-07-24", it is inserting as "24-JUL-24" which is wrong (year is wrong), it should suppose to be "24-JUL-16". It's happening once in a nth time. I was unable to debug the code, although I tried repeatedly inserting the data.
Could anyone please refer the below code, db schema and date format and let me know if I'm wrong anywhere. Thank you.
DAO Program
package com.oog.big.database;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.oog.big.database.DBConnection;
import java.text.SimpleDateFormat;
public class ItemDetailsDAO {
// format for date
public static final SimpleDateFormat transactionDateFormat = new SimpleDateFormat(
"yyyy-MM-dd");
public static transient final SimpleDateFormat requestDateTimeFormat = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
private static final String insertTableSQL = "INSERT INTO ITEM_DETAILS ("
+ " ITEM_ID ,"
+ " SRV_NAME ,"
+ " INS_TYPE ,"
+ " REQ_CONTEXT ,"
+ " STATUS_FLAG ,"
+ " CHL ,"
+ " TRANSACTION_DATE ,"
+ " REQ_DATETIME ,"
+ " FLAG )" + "values(?,?,?,?,?,?,?,?,?)";
public static void save() throws Exception {
Connection con = null;
PreparedStatement stmt = null;
try {
con = DBConnection.getConnection();
con.setAutoCommit(true);
stmt = con.prepareStatement(insertTableSQL);
stmt.setInt(1, 1256);
stmt.setString(2, "DD");
stmt.setString(3, "OL");
stmt.setString(4, "DP");
stmt.setString(5, "");
stmt.setString(6, "FF");
/** Incorrect Date **/
stmt.setDate(
7,
new java.sql.Date(transactionDateFormat.parse(
"2016-07-24").getTime()));
stmt.setDate(
8,
new java.sql.Date(requestDateTimeFormat.parse(
"2016-08-02T16:56:01.764-04:00").getTime()));
stmt.setString(9, "N");
stmt.execute();
stmt.close();
System.out.println("Completed!!");
} catch (Exception e) {
System.out.println("DB Error: "+e);
}
}
}
Schema for ITEM_DETAILS
CREATE TABLE OYD.ITEM_DETAILS
(
ITEM_ID INTEGER NOT NULL,
SRV_NAME VARCHAR2(5) DEFAULT NULL,
INS_TYPE VARCHAR2(3) DEFAULT NULL,
REQ_CONTEXT VARCHAR2(3) DEFAULT NULL,
REQ_DATETIME TIMESTAMP DEFAULT NULL,
STATUS_FLAG VARCHAR2(2) DEFAULT NULL,
CHL VARCHAR2(2) DEFAULT NULL,
TRANSACTION_DATE DATE DEFAULT NULL,
FLAG VARCHAR2(1) DEFAULT NULL,
LAST_UPDATE_TIMESTAMP TIMESTAMP DEFAULT SYSTIMESTAMP,
CONSTRAINT PK_ITEM_DETAILS PRIMARY KEY (ITEM_ID)
)
PARTITION BY RANGE (LAST_UPDATE_TIMESTAMP) INTERVAL (NUMTODSINTERVAL(1,'DAY'))
(
PARTITION P_ITEM_DETAILS VALUES LESS THAN (TO_DATE('07-MAR-2016','DD-MON-YYYY'))
)PARALLEL;
Specifications:
JAVA SE8
Oracle 12c database
JDBC Connector: ojdbc7-12.1.0.1.0.jar
Instead of formatting date using SimpleDateFormat, you can use Oracle's date function in your SQL.
private static final String insertTableSQL = "INSERT INTO ITEM_DETAILS ("
+ " ITEM_ID,"
+ " SRV_NAME,"
+ " INS_TYPE,"
+ " REQ_CONTEXT,"
+ " STATUS_FLAG,"
+ " CHL,"
+ " TRANSACTION_DATE,"
+ " REQ_DATETIME,"
+ " FLAG)" + "values(?,?,?,?,?,?,TO_DATE(?,'DD-MON-RR'),TO_DATE(?,'DD-MON-RR'),?)";
public static void save(){
//.........
smtp.setString(7,"24-07-2016");
smtp.setString(8,"02-8-2016");
//.........
You can even format time(hh:mm:ss) in TO_DATE() function to store timestamp.
I have a method for upgrading DB:
private void executeUpdateBatch(String... sql) throws SQLException {
JdbcConnection connJbdc = new JdbcConnectionImpl();
Connection conn = connJbdc.getConnection();
conn.setAutoCommit(false);
Statement st = conn.createStatement();
for(String s : sql) {
st.addBatch(s);
}
try {
// execute the batch
int[] updateCounts = st.executeBatch();
} catch (BatchUpdateException e) {
int[] updateCounts = e.getUpdateCounts();
checkUpdateCounts(updateCounts);
try {
conn.rollback();
} catch (Exception e2) {
}
throw new SQLException(e);
}
// since there were no errors, commit
conn.commit();
st.close();
conn.close();
}
And upgrade method:
public void upgradeTo5() throws SQLException {
executeUpdateBatch("CREATE TABLE project ("
+ "id INT(10) unsigned NOT NULL auto_increment, "
+ "title VARCHAR(255) NOT NULL, "
+ "date_from DATE NULL, date_to DATE NULL,"
+ "active BIT NOT NULL, PRIMARY KEY (id))",
"INSERT INTO project(titlea) VALUES('test1')");
}
An error is in INSERT just for testing rollback.
Well, the problem now is that it does not rollbacks CREATE TABLE project. Table is InnoDB. Any suggestions?
This is not supported by MySQL/InnoDB. All DDL statements (CREATE TABLE, ALTER TABLE, CREATE INDEX, DROP ...) always happen outside of transaction control.
This is a weak point that IIRC Postgres can handle better, but with MySQL you have to work around that by reverting the changes yourself in case of rollbacks.