Skip to main content

Thread: Did i misconfigure odbc ?


i have question on odbc on ubuntu 11.04

csharp test program:
code:
using system;  using system.data;  using system.data.odbc;    namespace odbctest  {  	class mainclass  	{  		  		  		// http://www.dbforums.com/delphi-c-etc/1608453-odbc-connection-mysql-c.html  		// http://www.java2s.com/code/asp/ado.net-database/mysqlodbcconnectionc.htm  		public static void mysql_odbc()  		{  			// unhandled exception: system.dllnotfoundexception: libodbc.so  			// apt-get install unixodbc-dev  			  			string strproduct = "test";  			strproduct = strproduct.replace("'", "''");  			  			string strodbcconnectionstring =  				"driver={mysql odbc 3.51 driver};server=localhost;" +  				"database=bind;uid=root;pwd=isnotsecure123456;";  			  			  			strodbcconnectionstring =   				"driver={mysql};server=localhost;" +  				"database=bind;uid=root;pwd=isnotsecure123456;";  			  			strodbcconnectionstring =   				"driver={firebird};dbname=localhost:/var/lib/firebird/2.5/data/employee.fdb;" +  				"user=sysdba;password=isnotsecure123456;";  			  			  			strodbcconnectionstring =   				"driver={mysqldns};server=localhost;" +  				"database=bind;uid=root;pwd=isnotsecure123456;";  			  			strodbcconnectionstring =   			"driver={myodbc 3.51 driver dsn};" +    			"server=localhost;database=bind;" +    			"uid=root;password=isnotsecure123456;" +    			"option=3"	;  			  			// http://www.connectionstrings.com/dsn  			  			// working  			strodbcconnectionstring =   			"dsn=mysql dns;" +  			"uid=root;" +    			"pwd=isnotsecure123456" ;  			  			  			// working mysql  			strodbcconnectionstring =   			"dsn=foobar;" +  			"uid=root;" +    			"pwd=isnotsecure123456" ;  			  			  			// not working  			strodbcconnectionstring =   			"dsn=foo;" +  			"uid=sysdba;" +    			"pwd=isnotsecure123456" ;  			  			  			// not working  			strodbcconnectionstring =   			"dsn=foo;" +   			"driver=firebird;" +   			"dbname=localhost:/var/lib/firebird/2.5/data/employee.fdb;" +   			"uid=sysdba;" +    			"pwd=isnotsecure123456" ;  			  			// error,   			//unhandled exception: system.data.odbc.odbcexception: error [hy000]   			//[unixodbc][mysql][odbc 5.1 driver]  			//access denied user 'sysdba'@'localhost' (using password: yes)  			  			/*  			strodbcconnectionstring =   			"dsn=\"firebird employees\";" +   			"uid=sysdba;" +    			"pwd=isnotsecure123456" ;  			*/  			  			  			  			  			// working mysql  			strodbcconnectionstring =   			"dsn=foobar;" +  			"uid=root;" +    			"pwd=isnotsecure123456" ;  			  			  			// working  			strodbcconnectionstring =   			"dsn=firebird employees;" +  			"uid=sysdba;" +    			"pwd=isnotsecure123456" ;  			  			strodbcconnectionstring =   			"dsn=firebird_nowhitespace;" +  			"" + //"driver=firebird;" +   			"" + //@"dbname=/var/lib/firebird/2.5/data/employee.fdb;" +   			"uid=sysdba;" +   			"pwd=isnotsecure123456";  			  			  			// http://www.devlist.com/connectionstringspage.aspx  			  			  			console.writeline(strodbcconnectionstring);  			  			 odbcconnection con = new odbcconnection(strodbcconnectionstring);  			              string strsql = @"insert product(product)   				                  values( """ + strproduct + @""" );";  			  			//strsql = @"select rdb$get_context('system', 'engine_version')               // version rdb$database;";  			  			con.open();  			console.writeline(strsql);  			              odbccommand cmd = new odbccommand(strsql, con);              try              {                  cmd.executenonquery();              }              catch (exception ex)              {  				console.writeline(ex.message);              }  			finally  			{  				con.close();  			}  			  		}  		  		  		public static void main (string[] args)  		{  			mysql_odbc();  			console.writeline ("hello world!");  		}  	}  }

, these odbc config file:


odbc.ini
code:
[odbc data sources]  foobar = "mysql dns"  fiem = foo    [firebird employees]  description = firebird  driver = firebird  dbname = localhost:/var/lib/firebird/2.5/data/employee.fdb  user = sysdba  password = isnotsecure123  role =  characterset =  readonly = no  nowait = no        [firebird_nowhitespace]  description = firebird  driver = firebird  dbname = localhost:/var/lib/firebird/2.5/data/employee.fdb  user = sysdba  password = isnotsecure123  role =  characterset =  readonly = no  nowait = no      [mysql dns]  driver = /usr/lib/odbc/libmyodbc.so  server = localhost  port = 3306  database = bind  option = 3  user = root  password = isnotsecure123  role =  characterset =  readonly = no  nowait = no    [mysqlvdns]  driver = mysql  server = localhost  port = 3306  database = bind  option = 3  user = root  password = isnotsecure123  role =  characterset =  readonly = no  nowait = no

odbcinst.ini
code:
[firebird]  description = interbase/firebird odbc driver  driver = /usr/lib/libodbcfb.so  setup = /usr/lib/libodbcfbs.so  threading = 1  fileusage = 1  cptimeout =  cpreuse =    [mysql]  description = odbc mysql  driver = /usr/lib/odbc/libmyodbc.so  setup = /usr/lib/odbc/libodbcmys.so  usagecount = 2

question:
seem able access odbc via dsn.
there reason ?

1. shouldn't able access odbc supplying info myself ?
2. works fine mysql, doesn't work firebird.

odbc itselfs seems work fine however, can connect via isql. did misconfigure firebird somewhere ?

3. must there plain text password in odbc.ini ?
can't hashed or encrypted, or left away ?

4. what's syntax [odbc data sources] ?
expect:
myrandom name = odbc source

, being able access "my odbc source" dsn="myrandom name" programmatically, doesn't seem work way...

bump.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [ubuntu] Did i misconfigure odbc ?


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support