mysql-connector

C# and MySQL .NET Connector - Any way of preventing SQL Injection attacks in a generic class?

吃可爱长大的小学妹 提交于 2019-11-27 20:51:09
My idea is to create some generic classes for Insert/Update/Select via a C# (3.5) Winforms app talking with a MySQL database via MySQL .NET Connector 6.2.2. For example: public void Insert(string strSQL) { if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(strSQL, connection); cmd.ExecuteNonQuery(); this.CloseConnection(); } } Then from anywhere in the program I can run a query with/without user input by just passing a SQL query string. Reading around on SO is starting to give me the indication that this may lead to SQL injection attacks (for any user-input values). Is

No server-side prepared statements using MySQL Connector/J

梦想与她 提交于 2019-11-27 16:58:57
问题 From what I understand, MySQL 5.1 supports server-side prepared statements. Therefore the following code should prepare the statement once, and execute it 10 times: Connection conn = ds.getConnection(); PreparedStatement stmt = conn.prepareStatement("SELECT COUNT(*) FROM users WHERE user_id=?"); for (int i=0; i<10; i++) { stmt.setString(1, "FOO"+i); ResultSet res = stmt.executeQuery(); res.close(); } stmt.close(); conn.close(); What I see instead in the mysqld log is the query being executed

ClassNotFoundException with com.mysql.cj.jdbc.Driver, MySQL Connector and IntelliJ IDEA

╄→尐↘猪︶ㄣ 提交于 2019-11-27 16:06:20
I'm building up a Maven Java 1.8 project in which I've included the MySQL Connector as a dependency: <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.39</version> </dependency> In my application I've a singleton that holds the MySQL connection so when the application starts, the MySQL connector is triggered but I got a ClassNotFoundException for the driver that I'm using: com.mysql.cj.jdbc.Driver . The JDBC URL that I'm using is: jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false I'm using IntelliJ IDEA (2017.2) IDE. I've checked in

mysql.h file can't be found

北城以北 提交于 2019-11-27 09:51:35
问题 i'm trying to install connection between c++ and mysql in ubuntu 12.04. i've installed mysql-client, mysql-server, libmysqlclient15-dev, libmysql++-dev. but when i try to compile the code i got the error: mysql.h there is no such file . i looked in the folders, there is mysql.h file, i can't understand why it can't find it. here is my code: /* Simple C program that connects to MySQL Database server*/ #include <mysql.h> #include <stdio.h> main() { MYSQL *conn; MYSQL_RES *res; MYSQL_ROW row;

(2059,“Authentication Plugin 'caching_sha2_password'”) when running server connected with MYSQL database on Django

十年热恋 提交于 2019-11-27 04:53:39
问题 I want to configure my django project in order to connect it with database in MYSQL I created with workbench 8.0 , and then I want to run the server by running python manage.py runserver from anaconda command prompt, so that I can use the Django interface to visualize and alter data. Please note that I don’t want to downgrade workbench 8.0. These are the steps I have made: From anaconda prompt: pip install mysqlclient In my project folder, in settings.py DATABASES = { 'default': { 'ENGINE':

Could not load file or assembly 'MySql.Data, Version=6.3.6.0

穿精又带淫゛_ 提交于 2019-11-27 03:39:55
问题 I'm at a COMPLETE loss - I'm having super wierd issues with what I still really dont even understand... I'm running Entity Framework 4.1, MySql 5.xx and my MySql Connector is v 6.4.4 - everything works beatifully locally however whenever I upload to the server I receive: Could not load file or assembly 'MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

How do I setup ASP.NET MVC 2 with MySQL?

*爱你&永不变心* 提交于 2019-11-27 02:46:28
Is it possible to setup ASP.NET MVC 2 to work with a MySQL database? I'm assuming that you have Visual Studio Professional 2008, have access to an instance of MySQL server, and have moderate to advanced development experience. This MAY work with VS2008 Web edition, but not at all sure. If you haven't, install MySQL Connector for .NET (6.2.2.0 at the time of this write-up) Optional: install MySQL GUI Tools If you haven't, install MVC 2 RTM , or better yet, use Microsoft's Web Platform Installer . ( UPDATE: MVC 2 has now been released for quite some time) Create an empty MySQL database. If you

Can't Create Entity Data Model - using MySql and EF6

邮差的信 提交于 2019-11-27 00:42:39
I'm trying to add an edmx Entity model to my C#/Web Project in Visual Studio 2013. My problem is that the file is not created. I do the following steps: Give the item a name Choose 'EF Designer from database' Choose the connection from the drop down (localhost) that already tested successfully connecting to MySQL databse The "Save connection settings in webc.config as" option is checked I click 'Next' AND the window disappeared and I get back to the code window No edmx file is created. (although it works with SQL Server, but not for MySQL) I have Entity Framework 6.1.2 installed, MySql.Data ,

How to connect to a MySQL Data Source in Visual Studio

倖福魔咒の 提交于 2019-11-26 22:28:29
I use the MySQL Connector/Net to connect to my database by referencing the assembly (MySql.Data.dll) and passing in a connection string to MySqlConnection . I like that because I don't have to install anything. Is there some way to "Choose Data Source" in Visual Studio 2010 without installing something? How can I get a MySQL option (localhost) to show up on one of these lists? Or do I have to install something? (I don't want to use ODBC btw) "Add Connection" from Server Explorer: Entity Data Model Wizard: Visual Studio requires that DDEX Providers (Data Designer Extensibility) be registered by

Replace table name with variable. Using python and mysql connector

喜夏-厌秋 提交于 2019-11-26 22:12:16
问题 I would like to dynamically change the variable name of the table I insert data into. This currently works, def dataEntry(subreddit, _title, _post_url, _imageURL): cnx = mysql.connector.connect(**config) c = cnx.cursor() insert = ("""INSERT INTO FoodPorn (subreddit, title, post_url, imageURL) VALUES (%s, %s, %s, %s)""") data_value = (subreddit, _title, _post_url, _imageURL) c.execute(insert, data_value) cnx.commit() c.close() cnx.close() dataEntry("fake", "fake", "fake", "fake") but when I