pdo,database-connectionRelated issues-Collection of common programming errors


  • Mike Causer
    php sql sql-server pdo
    I am trying to create a simple PHP page that describes the tables of my DB so I can always find a table/column name or data type that I am looking for (a sort of poor man’s schema if you will).I have done this in the past with a Sybase DB but our new DB will be SQL Server so I am trying to reproduce it using that DB.try {$conn = new PDO(“odbc:Driver={SQL Native Client};Server=servername,1433;Database=dbname;Uid=user;Pwd=password;”);$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTIO

  • Howard
    mysql pdo
    My Mysql server often crashes, and I need to restart mysql using “service mysqld start” command. I check the mysql error log file.130807 22:59:47 mysqld_safe Number of processes running now: 0 130807 22:59:47 mysqld_safe mysqld restarted 130807 22:59:47 [Note] Plugin ‘FEDERATED’ is disabled. 130807 22:59:47 InnoDB: The InnoDB memory heap is disabled 130807 22:59:47 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130807 22:59:47 InnoDB: Compressed tables use zlib 1.2.5 130807 22:59:47 InnoDB

  • Amirshk
    php mysql pdo
    This is a security question meant for PDO prepared statements. Using PDO I know that the risk of sql injection is virtually impossible and that the class handles all of that for you. Coming from using them mysql_* stack I always feel as if I’m not handling security issues well enough. I’m usually used to writing hundreds of lines of code just to deal with security while now I’m literally just writing queries. Is there really any security threats with PDO statements that I have to worry about oth

  • Polsonby
    php mysql pdo mysqli database-abstraction
    In our place we’re split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS.I prefer PDO for the single reason that it allows named parameters for prepared statements, and as far as I am aware mysqli does not.Are there any other pros and cons to choosing one over the other as a standard as we consolidate our projects to use just one approach?

  • Stuart Thomson
    php sql sql-server pdo odbc
    I’ve come across something that doesn’t quite make sense. I noticed a weird occurrence that happens when you try to return data from a SQL Server database to PHP. If you use the SQL Sever Native Client driver in PHP, NVARCHAR(MAX) is supposed to be returned as a stream type according to articles online. In SQL Server Management Studio if I create a new table with these datatypes the nvarchar(max) field is returned as a stream:[PK][int] [nvarchar(255)] [nvarchar(max)]If I create a table using the

  • BigBob
    sql-server pdo
    When I try to insert a record with date/time into MSSQL 2008 datetime field like this$pQuery = “INSERT INTO myTable (myDate) VALUES (:my_date)”; $ps = $pdo->prepare($pQuery); $ps->bindValue(“my_date”, date(“Y-m-d H:i:s”,strtotime(‘01.07.2013’)), PDO::PARAM_STR); $ps->execute();with a string ‘01.07.2013’ (DD.MM.YYYY) representing July 1st 2013, I end up with a value of ‘2013-01-07 00:00:00’ in the table which represents January 7th 2013. If the day is bigger than 12, insert fails with PD

  • SoaperGEM
    php sql sql-server pdo prepared-statement
    Note: the only difference in the following examples is the ORDER BY clause.Good code:$sql = ‘SELECT [date], ? AS [name] FROM [transactions] WHERE [category_id] = 10 GROUP BY [date] ORDER BY [date] ASC’;$stmt = $db->prepare($sql); $stmt->bindValue(1, ‘Test’, PDO::PARAM_STR); $stmt->execute(); $data = $stmt->fetchAll(); //returns rows in $dataBad code:$sql = ‘SELECT [date], ? AS [name] FROM [transactions] WHERE [category_id] = 10 GROUP BY [date] ORDER BY [date] ASC, [name] ASC’

  • Question Overflow
    php mysql pdo
    From the PHP manual, it states that:PDO::ATTR_EMULATE_PREPARES Enables or disables emulation of preparedstatements. Some drivers do not support native prepared statements orhave limited support for them. Use this setting to force PDO to eitheralways emulate prepared statements (if TRUE), or to try to use nativeprepared statements (if FALSE). It will always fall back to emulatingthe prepared statement if the driver cannot successfully prepare thecurrent query. Requires bool.I have a query that go

  • Mansoor
    php sql-server pdo connection odbc
    I’m trying to connect using a string:odbc:Driver={SQL Server Native Client 11.0};Server=(localdb)\v11.0;Database=test;uid=sa;password=123321;Result: SQLSTATE[28000] SQLDriverConnect: 18456 [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user ‘sa’.When I try to connect using Windows ODBC Data Source Administrator the connection is successful.What the problem might be in?

  • sharif
    php pdo centos5 rpmbuild
    I am trying to build php from rpm source and it fails on centos 5 32bit. building of php 5.2.6. I get error as follows:Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/php-5.2.6-2-root-root error: Installed (but unpackaged) file(s) found:/usr/lib/php/modules/pdo_dblib.soRPM build errors:Installed (but unpackaged) file(s) found:/usr/lib/php/modules/pdo_dblib.soI want to build including pdo_dblib so I did make some modifications but not sure what i have changed. Following is what

  • Nadeem_MK
    c# database-connection user-defined-functions access-violation jna
    I use JNA to call a 3. party provided .dll written in C#. This is my code using the dll:public class Main{ public interface AirtrackDLL extends Library{AirtrackDLL INSTANCE = (AirtrackDLL)Native.loadLibrary(“atproc32.dll”,AirtrackDLL.class); static interface TestPing extends Callback{short invoke(short param);} static interface TestDBConnection extends Callback{short invoke();}public short TestPing(TestPing callbackparam);public short TestPing(short param);public short TestDBConnection(TestDB

  • puk
    java jdbc database-connection derby sqlexception
    I have written a test program that makes a Derby connection and creates the necessary tables if they do not exist. But once I run the programme I can’t rerun it again because the exception I have brought. I think that I should add a finilize method to the current singletone class and close the connection there. Is it the solution?But anyway I consider the possiblity of the program crash and exiting from the program in an abnormal manner. In that case how can I force to close the other instances

  • APC
    sql-server-2005 oracle ssis database-connection
    I have an SQL 2005 SSIS package that takes data from an Oracle DB Table, and transfers it to a SQL Server Table.I have set up an “Oracle Provider for OLE DB” for the Oracle connection and a “SQL Native Client” for SQL Server Connection.The Oracle and SQL connections will depend on the development and shipping stage, which are:Local environment SYS – For integration and System testing UAT – For user acceptance testing PRE – Mimics the LIVE system for confidence testing Live – The live systemIn th

  • Kara
    junit database-connection spring-batch
    If I run all(31) the unit test together, I get following connection error in 2 – 3 unit tests, however if I run those tests individually, the run successfully. Can you please guide me on this strange behaviour. I am using Spring 3.0.6, Spring batch 2.1.7 and Oracle XE database. below is the error java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308) at org.springframework.test.context.sup

  • elyana
    java jdbc database-connection
    I’m new using Intellij 13 and I have a problem on connection to mysql. I’m using the code as below and this code I learn from tutorials Manage Your Database Scheme with Intellij IDEA 12. public class App {public static final String JDBC_DRIVER = “com.mysql.jdbc.Driver”; public static final String JDBC_URL = “jdbc:mysql://localhost/sample”; public static final String JDBC_USER = “root”; public static final String JDBC_PASSWORD = “”;public static void main (String[] args) throws SQLException, Cl

  • Ed Harper
    c# sql sql-server tsql database-connection
    I have a entry in SQL Server Configuration Manager>SQL Native client Configuration > AliasesAlias Name : CRM_APP Port : 5051 Protocol: TCP/IP Server: 10.10.10.10\MYSERVERI am connecting to SQL using Servername : CRM_APPHow can we detect if a SQL connection is using Alias (basically i want to know the actual IP address of the Server that the client is using) to connect to the Server using SQL or C#?Clearer explanation of requirement copied from comments:Basically I want to restrict Winforms Appli

  • Marius
    java mysql jdbc database-connection
    I have this Java application in which I am now developing a module that can read and execute SQL statements from a file and output the results of the queries. If I launch the module via its main method, it works fine. I give the path to the DB connection settings file (with the user, pass, port.. etc), the path to a file containing SQL queries and the name of the output file. As I said, launched as stand alone, it works fine, connects with no problem, executes queries and outputs their results.

  • marc_s
    asp.net sql-server odbc database-connection oledb
    I am having some trouble with a connection string between an ASP app sat on IIS and an existing SQL Server 2012 instance.The current connection string that works is as follows: Data Source=SERVER1;Initial Catalog=CORE;UserID=testuser;Password=password;MultipleActiveResultSets=true;Connection Timeout=200;pooling=falseThe ODBC driver installed is SQL Server V 6.01.7601.17514. I then added the latest driver SQL Server Native Client 11 and tried adjusting the connection string in IIS with no luck.I

  • KrisG
    mysql ruby-on-rails database-connection
    I already have a mysql server setup via MAMP.But when trying to install the mysql Rails client (gem install mysql2) I get the following error:ERROR: Failed to build gem native extension./Users/krisgandhi/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rbchecking for mysql_query() in -lmysqlclient… nochecking for main() in -lm… yeschecking for mysql_query() in -lmysqlclient… nochecking for main() in -lz… yeschecking for mysql_query() in -lmysqlclient… nochecking for main() in -lsocket… n

  • Bula
    java database database-connection derby
    I’m trying to build a simple spring app which needs to have the ability to communicate with a database. Following a tutorial I have completed the entire code of my app however when I run my app I get this:Exception in thread “main” java.lang.IllegalStateException: Could not load JDBC driver class [org.apache.derby.jdbc.EmbeddedDruver]at org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(DriverManagerDataSource.java:130)at main.Application.main(Application.java:15) Cau

Web site is in building