mysql-connector

Class Not Found Exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver? [duplicate]

非 Y 不嫁゛ 提交于 2019-12-13 09:14:11
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: com.mysql.jdbc.Driver not found with mysql connector in buildpath I'm working on connecting MySQL database to a Java program. When I run my program I am getting this error Class Not Found Exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver for this line try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); So, what's the problem? I'm placing the connector in the project's file.. Is the

Why are the insert batch times increasing?

我们两清 提交于 2019-12-13 07:13:42
问题 Summary: Inserting 100k rows at a time with 1k batches (yes it's definitely being batched) and time to insert is increasing for each batch. Trying to understand why. Original Question: JProfiler shows a lot of time spent reading an InputStream in ReadAheadInputStream.fill. Update: Per comment below from EJP "The time is being spent blocked in read(), while the database server is executing the statement and preparing the response" What could cause so much time to be spent here? Details:

Wait for other transaction to commit/rollback before beginning another transaction?

∥☆過路亽.° 提交于 2019-12-13 04:30:05
问题 How can I make my transactions to wait if there is still an un-committed/un-roll-backed transaction in MySQL? Currently I do my transactions on the code side, not on the DB Stored Procedure side, like this: cmd.Connection.BeginTransaction(); try { // db codes here cmd.Transaction.Commit(); } catch { cmd.Transaction.Rollback(); throw; } finally { cmd.Connection.Close(); } I want for other transactions to wait until the previous transaction is finished. Since I have, in some of my stored proc,

Migration to Mysql Connector Jar 5.1.27

情到浓时终转凉″ 提交于 2019-12-13 01:25:27
问题 I have just replaced my mysql connector jar 3.1.12 to 5.1.27. and getting error You need to specify Statement.RETURN_GENERATED_KEYS to the Statement.executeUpdate() or Connection.prepareStatement(). I got the solution that i should use PreparedStatement ps = connection.prepareStatement(SQL, Statement.RETURN_GENERATED_KEYS); instead PreparedStatement ps = connection.prepareStatement(SQL); The main problem is how can I replace this in whole project and is there any method to set it globally? Is

c++ mysql connection bad_alloc using c++ connector

两盒软妹~` 提交于 2019-12-12 19:34:16
问题 Trying to build a simple mysql connection, but getting a bad_alloc and I can't figure out how to solve this, even looking at similar posts here is my code #include <iostream> #include <stdlib.h> #include <sstream> #include <memory> #include <string> #include <stdexcept> #include "mysql_connection.h" #include "cppconn\driver.h" #include "cppconn\statement.h" #include "cppconn\connection.h" #include "cppconn\exception.h" #include "cppconn\prepared_statement.h" #include "cppconn\statement.h"

How do you know when GroovyStrings are not treated the same as Strings?

泪湿孤枕 提交于 2019-12-12 18:24:27
问题 I've just run into a confusing issue in Groovy while trying to modify a MySQL database. What appears to be identical code throws an Exception unless my GroovyString is explicitly converted to a java.lang.String : import groovy.sql.Sql def sql = Sql.newInstance('jdbc:mysql://localhost/test?useUnicode=yes&characterEncoding=UTF-8', 'user', 'pass', 'com.mysql.jdbc.Driver') def tableName = 'my_table' sql.execute "truncate $tableName" throws: com.mysql.jdbc.exceptions.jdbc4

mysql.connector bug during “except” when compiled with pyinstaller?

廉价感情. 提交于 2019-12-12 11:44:36
问题 I have a python program which makes mysql calls that I build into an exe using pyinstaller. The following problem occurs with either a --onefile or a --onedir compile using pyinstaller. I have been able to use either mysqldb or mysql.connector to successfully connect and make queries. Here is the mysqldb connect logic: # from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python try: db = MySQLdb.connect(host=hostname,user=username,passwd=password) except MySQLdb.Error as e: reply = QtGui

Why does mysql c++ connector work in main() but not in a class method?

前提是你 提交于 2019-12-12 06:33:04
问题 This code works if it's in main: int main(void) { cout << endl; cout << "Running statement." << endl; try { sql::Driver *driver; sql::Connection *con; sql::Statement *stmt; /* Create a connection */ driver = get_driver_instance(); con = driver->connect("address:port", "user", "pass"); /* Connect to the MySQL test database */ con->setSchema("database"); stmt = con->createStatement(); stmt->execute("TRUNCATE TABLE words"); delete stmt; delete con; } catch (sql::SQLException &e) { cout << "# ERR

Start and Stop mysql through java

陌路散爱 提交于 2019-12-12 05:58:58
问题 I want to start and stop mysql through java program. I tried solution from this question, but it failed to start the mysql. Then I tried using other commands as below: private static String commandStart = SQL_INSTALL_DIR + "/bin/mysqld"; private static String commandStop = SQL_INSTALL_DIR + "/bin/mysqld -u root shutdown"; public static void main(String[] args) { Connection con = null; Statement st = null; ResultSet rs = null; startMysql(); String url = "jdbc:mysql://localhost:3306/testdb";

How to protect user specified table name from SQL Injection in C#, using MySQL

徘徊边缘 提交于 2019-12-12 04:44:20
问题 As a reaction to MySqlParameter as TableName, it seems that MySQL's Connector/NET library doesn't support table names from user input in the following way: MySqlCommand cmd = new MySqlCommand("SELECT * FROM @table"); cmd.Parameters.AddWithValue("@table",TableNameFromUserInput); So I tried to find another way, but I couldn't find any libraries that did this for me. When searching for how to do this manually, I couldn't found anything that didn't tell you to use "prepared statements" from some