How to use JDBC connector in mac to connect mssql - osx-lion

I am trying to use the JDBC connector to connect to mssql, how to use in Xcode 4.2, or in command prompt, Right now I am using OSX 10.7.3
IS there any sample example is there.

This tutorial have detailed explanation: http://www.vogella.com/articles/MySQLJava/article.html. The site is just awesome and has many other great tutorials!
In short:
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection("jdbc:mysql://localhost/dbname?user=sqluser&password=sqluserpw");
statement = connect.createStatement();
resultSet = statement.executeQuery("SELECT * FROM dbname.tablename");
Is this what you need?

Related

How to connect Power BI to PostgreSQL

I want get data into Power BI desktop from PostgreSQL (on my local machine). I tried the solution given here (Installing ngpsql to use PostgreSQL in PowerBI), but it did not work.
Basically, I installed the latest version of ngpsql(3.2.4) with the option to install to GAC. However, I'm getting the same error in Power BI saying that the connector requires one or more additional components.
Am I missing any steps? I looked online but did not find any recent documentation on this.
Any help is very much appreciated.
Thanks
Three ways :
1 - The ngpsql way does work if your follow the comment of Lavande:
Install npgsql as Administrator (since the DLL would be pushed to GAC);
During the installation stage, enabled "Npgsql GAC Installation";
Restart the PC
2 - With ODBC, i used this walk-through
install ODBC connector here
start it and create a new connection (DSN)
in Power BI, get data, ODBC,PostGreSQL, no options
enter the credentials.
select the table(s) of interest.
3 - With the M query language.
Nota : the Power BI community posts ? well, ...
Another option to solve this problem is to create a Python script to connect to Postgresql.
Using a script like this:
import psycopg2
import pandas as pd
con = psycopg2.connect(host='localhost', database='Your DataBase',
user='user', password='password')
cur = con.cursor()
cur.execute('Your Query')
data = cur.fetchall()
df = pd.DataFrame(data, columns=['Your Columns'])

Is it possible to connect to a PostgreSQL server using FreeTDS driver and tsql?

I've asked this question on serverfault and someone told me to ask here.
Can I make a connection to a PostgreSQL server using FreeTDS, more specifically using the tsql command?
I've been trying for a few days now, using many different configurations. Even though I am able to connect to the DB using isql and PostgreSQL odbc driver, I can't make it work using tsql (it also doesn't seem to use odbc.ini or odbcinst.ini). So, I was wondering if the tsql command only works with SQL Server.
If you want, I can post the files freetds.conf, odbc.ini and odbcinst.ini.
Thanks.
FreeTDS only supports the TDS protocol (hence the name). And this protocol is only implemented by Microsoft SQL Server and the Sybase database.
So, no you can not use FreeTDS to connect to a Postgres database.
You need to use the Postgres ODBC driver, the Postgres .Net driver or the Postgres JDBC driver to do this - depending on the programming language of your application. From a C program you can also connect to Postgres directly using the libpq library.

Connect icCube with Reshift

in icCube 5.1 there is no Redshift as list of supported JDBC connections.
How to create a data source in icCube on Amazon Redshift ?
A first solution is using the Postgres jdbc driver. Redshift is based on Postgres so it also works (for how long is a good question).
The second is a bit more complicated as you need to add Reshift jdbc driver to icCube. First download jdbc driver from amazon from here, after follow this instructions to add a library to icCube.
Once done you've to configure a new data-source :

Unable to connect to oracle database using os authentication?

I am trying to connect to oracle database using os authentication through jdbc.
I have oracle 10g installed on solaris sparc 32 bit.
Following is the code for jdbc connection :-
String url = "jdbc:oracle:thin:#oracleserver.mydomain.com:5521:dbja"
Driver driver = new oracle.jdbc.OracleDriver();
DriverManager.registerDriver(driver);
Properties props = new Properties();
props.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,"oracle");
Connection conn = DriverManager.getConnection( url, props);
when i run the above code using thin driver, it gives error as "invalid username/password ; logon denied'
using oci driver error is :: "no ocijdbc11 in java.library.path" but i am using oracle 10g and in LD_LIBRARAY_PATH libocijdbc10.so is present. but still looking for libocijdbc11.so.
Please help me to resolve the issue.
Thanks
For using os authentication, please check the oracle documentation
How is the os_authent_prefix?
Does the user oracle exist?
Is REMOTE_OS_AUTHENT = TRUE?
For OCI access, the relevant thing here is the JDBC driver, which must match the oracle client version. To achieve this, add the 10g jdbc driver from your oracle client installation to the class path.

What is the connectionstring to connect with postgresql using ODBC driver?

I am currently working with a task to connect with PostgreSQL and retrieve data from that DB to my .net application,I am using the code like
OdbcConnection con = new OdbcConnection("Driver={PostgreSQL };Server=localhost;Port=2012;Database=DataCenter;Uid=postgres;Pwd=post#123;");
but it is throwing an ODBException. Please suggest me a code.
You may try that:
Driver={PostgreSQL};Server=IP
address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
You can definitely find more information on this website: http://www.connectionstrings.com/
And in your case particularely on this page: http://www.connectionstrings.com/postgre-sql#p51
If it does not solve your problem it is that the problem doesn't come from the connection string but your configuration of PostgreSQL. You might want to check that you're able to connect to the server using "psql" (for example) from your client computer.
Regards
For Ex:
string connstring = String.Format("Server={0};Port={1};User Id={2};Password={3};Database={4};",
"localhost", "5432", "postgres", "metin", "ATALAY");