Sunday, March 25, 2012
Connecting to SQL from JBuilder
I am trying to connect to a SQL Server Database from an aplication in java, but I received the following error: No suitable driver
I am using JDBC and a ODBC connection call TP2. My string connection look like this
Connection con = DriverManager.getConnection ("jdbc:odbc:TP2", "sa", "sql");
What I do not have clear enought is where should I copy my jar files ??
I really appreciate your help !!!!!!!!!!!!!!
BRthis link may help u. http://forum.java.sun.com/thread.jspa?threadID=720810
and this, http://www.devdaily.com/java/edu/pj/pj010024/ if it is a connection error.
I ve no idea about the jar file u mentioned,better u post ur question in java forum.|||Download the MS JDBC driver or the jTDS JDBC driver
Sunday, March 11, 2012
connecting to database
I was trying to connect to datatbase on my computer, through java. I understand that I will need to download JDBC driver for that. But i am not sure which driver will I need, and where do i need to put it. Do I have to make some changes in CLASSPATH as well?
I am using SQL 2000. My jdk profile is j2sdk1.4.2.01. Also what is subname in
jdbc:<subprotocol>:<subname>
is it the name of database or what?
In need of help !!!!!!
thanks in advanceThe jdbc drive should be in the classpath and added to your project (depends on your environment).
I believe that the subname is the database (could be its ip), with subprotocol being the driver, for db2 its db2, not sure thought for sql 2000.
Are you creating a standalone java application and appled or jsp ?
Friday, February 24, 2012
connecting msde to java code
msde on a local machine how can ,I connect to tthis database using
java.I am completely new to msde
should I use jdbc drivers or connect through tcp connection.I think JDBC is on right track.
http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
"saikiran2012@.gmail.com" wrote:
> I have a java code which has to read from the database ,I am running
> msde on a local machine how can ,I connect to tthis database using
> java.I am completely new to msde
> should I use jdbc drivers or connect through tcp connection.
>
connecting msde to java code
msde on a local machine how can ,I connect to tthis database using
java.I am completely new to msde
should I use jdbc drivers or connect through tcp connection.I think JDBC is on right track.
http://support.microsoft.com/defaul...kb;en-us;313100
"saikiran2012@.gmail.com" wrote:
> I have a Java code which has to read from the database ,I am running
> msde on a local machine how can ,I connect to tthis database using
> java.I am completely new to msde
> should I use jdbc drivers or connect through tcp connection.
>
Sunday, February 19, 2012
Connecting JDBC with SQL Server, error establishing socket
server...
heres the code I altered provided my microsoft to test this connection:
import java.sql.*;
class test {
public static void main(String args[]) {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:datadirect:sqlserver://dbserver:1433;DatabaseName=sample",
"sa", "");
conn.close();
System.out.println("ok");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Heres the error messages:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establis
hing socket.
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown
Source
)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown
Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown
Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<in it>(Unknown
Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnecti on.open(Unknown
Sou
rce)
at
com.microsoft.jdbc.base.BaseConnection.getNewImplC onnection(Unknown S
ource)
at com.microsoft.jdbc.base.BaseConnection.open(Unknow n Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at test.main(test.java:12)
thanks
It appears that you do not have access to your db server machine.
try ping command for the IP address.
This has to do with the network settings.
I use MSSQLServer driver and It seems that my DB-URL is different.
DRIVER=com.microsoft.jdbc.sqlserver.SQLServerDrive r
URL=jdbc:microsoft:sqlserver://localhost:1433;SelectMethod=cursor
this works fine.
Message posted via http://www.sqlmonster.com
Connecting JDBC with SQL Server
server...port 1433 is what sql server is running off of..my password
and username are correct..ive tried the ip, comp name and localhost for
server name and I cant make a connection to it...
heres the code I altered provided my microsoft to test this connection:
public class Connect{
private java.sql.Connection con = null;
private final String url = "jdbc:microsoft:sqlserver://";
private final String serverName= "192.168.1.102";
private final String portNumber = "1433";
private final String databaseName= "KB";
private final String userName = "kbuser";
private final String password = "password";
// Informs the driver to use server a side-cursor,
// which permits more than one active statement
// on a connection.
private final String selectMethod = "cursor";
// Constructor
public Connect(){}
private String getConnectionUrl(){
return
url+serverName+":"+portNumber+";databaseName="+dat abaseName+";selectMethod="+selectMethod+";";
}
private java.sql.Connection getConnection(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
con =
java.sql.DriverManager.getConnection(getConnection Url(),userName,password);
if(con!=null) System.out.println("Connection
Successful!");
}catch(Exception e){
e.printStackTrace();
System.out.println("Error Trace in getConnection() : " +
e.getMessage());
}
return con;
}
/*
Display the driver properties, database details
*/
public void displayDbProperties(){
java.sql.DatabaseMetaData dm = null;
java.sql.ResultSet rs = null;
try{
con= this.getConnection();
if(con!=null){
dm = con.getMetaData();
System.out.println("Driver Information");
System.out.println("\tDriver Name: "+
dm.getDriverName());
System.out.println("\tDriver Version: "+
dm.getDriverVersion ());
System.out.println("\nDatabase Information ");
System.out.println("\tDatabase Name: "+
dm.getDatabaseProductName());
System.out.println("\tDatabase Version: "+
dm.getDatabaseProductVersion());
System.out.println("Avalilable Catalogs ");
rs = dm.getCatalogs();
while(rs.next()){
System.out.println("\tcatalog: "+
rs.getString(1));
}
rs.close();
rs = null;
closeConnection();
}else System.out.println("Error: No active Connection");
}catch(Exception e){
e.printStackTrace();
}
dm=null;
}
private void closeConnection(){
try{
if(con!=null)
con.close();
con=null;
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception
{
Connect myDbTest = new Connect();
myDbTest.displayDbProperties();
}
}
Heres the error messages:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.Error Trace in getConnection() :
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
Error: No active Connection
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown
Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<in it>(Unknown
Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnecti on.open(Unknown
Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplC onnection(Unknown
Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknow n Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at Connect.getConnection(Connect.java:36)
at Connect.displayDbProperties(Connect.java:53)
at Connect.main(Connect.java:89)
thanks
-Jim
Jim,
There could be a number of reasons why a connection can't be
established: server not running, TCP/IP not enabled on the server, a
firewall blocking the connection etc. Check all these and until "telnet
<server_host> 1433" won't connect, the JDBC driver won't connect either
(unless it used named pipes).
Alin,
The jTDS Project.
|||Yep...I could not telnet to that port and when I did a netstat sql
server wasnt listening on that port...
To fix this I upgraded from the RTM to service pack3...rebooted and was
able to connect just fine...
Thanks
-Jim
Tuesday, February 14, 2012
Connect to SSAS on TCP/IP using Java + execute XMLA
Hi,
I have done this in .Net, but that is easy because you get .Net libraries to help you connect and send XMLA over TCP/IP.
I would want to do the same using Java:
Connect to SSAS 2005 on TCP/IP, or even SOAP over TCP/IP
Then execute XMLA commands
and retrieve XMLA responses.
How to accomplish this?
Regards
Vijay R
The TCP/IP bindings to XMLA that AS use as proprietrary and also patented, therefore you cannot connect directly over TCP/IP to AS. You can use HTTP instead.|||
Hi Mosha,
Thanks a lot,
But to use HTTP we need to use IIS,
any other way to do this?
Regards
Vijay R
|||But to use HTTP we need to use IIS
Yes. What is a problem with using IIS ?
|||Hi Mosha,
Thanks for the quick reply,
No problem with IIS, but the dependency increases and my customer does not want to spend extra on another server.
They use java based servers like JMS.
I have told them that either we need to use AMO.Net in an .Net code or use IIS.
The problem is because of the xmla specification and ssas 2005 information given in books,
My customer points out to me that we can do an SOAP over tcp/ip and pass XMLA commands, as printed in the books!
I am not finding a valid technical angle to tackle this.
apart from that I had another related question:
we can use oledb and connect to ssas2005, right?
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
2) the new jdbc driver for sql 2005, does it allow to connect to ssas 2005?
Thanks once more mosha
Regards
|||No problem with IIS, but the dependency increases and my customer does not want to spend extra on another server
There is no need to spend extra on another server. You can have IIS and Analysis Services server on the same machine.
My customer points out to me that we can do an SOAP over tcp/ip and pass XMLA commands, as printed in the books!
Your customer is wrong. He cannot do that. Microsoft's OLEDB driver and ADOMD.NET can do that, but as I pointed earlier the TCP/IP bindings to XMLA are proprietrary and patent protected.
we can use oledb and connect to ssas2005, right?
Correct
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
Yes
2) the new jdbc driver for sql 2005, does it allow to connect to ssas 2005?
No
|||Hi Mosha,
Thanks a lot :-)
I have been quite a fan of yours!! I am currently in the US, any chance that you are here?
If possible, I was hoping to meet you.
No problem anyway, bye
Thanks again.
Regards
Vijay R
|||
Hi Mosha,
I can java, but donn't like it, therevore i use .Net pure and can communicate with SSAS through XMLA over TCP from my own code without adomd.net and other proprietary junk. Yes I haven't compression and encription, but it runs!!!
What law I break?
|||Hi,
I tried some java code,
that opens a socket connection and sends the xmla in a soap envelope as a string.
but the connections itself in ssas profiler displays as anonymous logon,
the query does not come through to the server at all !
Regards
Vijay R
|||Hi all,
When reading the following statements by Mosha, i was very excited:
we can use oledb and connect to ssas2005, right?
Correct
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
Yes
Then I had to ask... How? Do I need to use a different provider / connection string? Do I need to wrap my XMLA in anything? Where can I find further information on this.
Thankyou
Aranda
|||You should send SSPI handshacke info. How to obtain it in java I don't know. In the .Net it is pretty easy.
|||Hi,
can you please explain in detail as to how to send the SSPI handshake info In a .net program?
it would be helpful if you can give a code snippet that expains the procesure.
Regards
|||Hi,
Mosha wrote "as I pointed earlier the TCP/IP bindings to XMLA are proprietrary and patent protected."
Therefore here is not a right place to speak it about.
Regards
|||:-)
So how about this Vladimir Chtepa: vijay_rb@.yahoo.com
in any case, thanks for the interaction.
Regards
Connect to SSAS on TCP/IP using Java + execute XMLA
Hi,
I have done this in .Net, but that is easy because you get .Net libraries to help you connect and send XMLA over TCP/IP.
I would want to do the same using Java:
Connect to SSAS 2005 on TCP/IP, or even SOAP over TCP/IP
Then execute XMLA commands
and retrieve XMLA responses.
How to accomplish this?
Regards
Vijay R
The TCP/IP bindings to XMLA that AS use as proprietrary and also patented, therefore you cannot connect directly over TCP/IP to AS. You can use HTTP instead.|||
Hi Mosha,
Thanks a lot,
But to use HTTP we need to use IIS,
any other way to do this?
Regards
Vijay R
|||But to use HTTP we need to use IIS
Yes. What is a problem with using IIS ?
|||Hi Mosha,
Thanks for the quick reply,
No problem with IIS, but the dependency increases and my customer does not want to spend extra on another server.
They use java based servers like JMS.
I have told them that either we need to use AMO.Net in an .Net code or use IIS.
The problem is because of the xmla specification and ssas 2005 information given in books,
My customer points out to me that we can do an SOAP over tcp/ip and pass XMLA commands, as printed in the books!
I am not finding a valid technical angle to tackle this.
apart from that I had another related question:
we can use oledb and connect to ssas2005, right?
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
2) the new jdbc driver for sql 2005, does it allow to connect to ssas 2005?
Thanks once more mosha
Regards
|||No problem with IIS, but the dependency increases and my customer does not want to spend extra on another server
There is no need to spend extra on another server. You can have IIS and Analysis Services server on the same machine.
My customer points out to me that we can do an SOAP over tcp/ip and pass XMLA commands, as printed in the books!
Your customer is wrong. He cannot do that. Microsoft's OLEDB driver and ADOMD.NET can do that, but as I pointed earlier the TCP/IP bindings to XMLA are proprietrary and patent protected.
we can use oledb and connect to ssas2005, right?
Correct
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
Yes
2) the new jdbc driver for sql 2005, does it allow to connect to ssas 2005?
No
|||Hi Mosha,
Thanks a lot :-)
I have been quite a fan of yours!! I am currently in the US, any chance that you are here?
If possible, I was hoping to meet you.
No problem anyway, bye
Thanks again.
Regards
Vijay R
|||
Hi Mosha,
I can java, but donn't like it, therevore i use .Net pure and can communicate with SSAS through XMLA over TCP from my own code without adomd.net and other proprietary junk. Yes I haven't compression and encription, but it runs!!!
What law I break?
|||Hi,
I tried some java code,
that opens a socket connection and sends the xmla in a soap envelope as a string.
but the connections itself in ssas profiler displays as anonymous logon,
the query does not come through to the server at all !
Regards
Vijay R
|||Hi all,
When reading the following statements by Mosha, i was very excited:
we can use oledb and connect to ssas2005, right?
Correct
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
Yes
Then I had to ask... How? Do I need to use a different provider / connection string? Do I need to wrap my XMLA in anything? Where can I find further information on this.
Thankyou
Aranda
|||You should send SSPI handshacke info. How to obtain it in java I don't know. In the .Net it is pretty easy.
|||Hi,
can you please explain in detail as to how to send the SSPI handshake info In a .net program?
it would be helpful if you can give a code snippet that expains the procesure.
Regards
|||Hi,
Mosha wrote "as I pointed earlier the TCP/IP bindings to XMLA are proprietrary and patent protected."
Therefore here is not a right place to speak it about.
Regards
|||:-)
So how about this Vladimir Chtepa: vijay_rb@.yahoo.com
in any case, thanks for the interaction.
Regards
Connect to SSAS on TCP/IP using Java + execute XMLA
Hi,
I have done this in .Net, but that is easy because you get .Net libraries to help you connect and send XMLA over TCP/IP.
I would want to do the same using Java:
Connect to SSAS 2005 on TCP/IP, or even SOAP over TCP/IP
Then execute XMLA commands
and retrieve XMLA responses.
How to accomplish this?
Regards
Vijay R
The TCP/IP bindings to XMLA that AS use as proprietrary and also patented, therefore you cannot connect directly over TCP/IP to AS. You can use HTTP instead.|||
Hi Mosha,
Thanks a lot,
But to use HTTP we need to use IIS,
any other way to do this?
Regards
Vijay R
|||But to use HTTP we need to use IIS
Yes. What is a problem with using IIS ?
|||Hi Mosha,
Thanks for the quick reply,
No problem with IIS, but the dependency increases and my customer does not want to spend extra on another server.
They use java based servers like JMS.
I have told them that either we need to use AMO.Net in an .Net code or use IIS.
The problem is because of the xmla specification and ssas 2005 information given in books,
My customer points out to me that we can do an SOAP over tcp/ip and pass XMLA commands, as printed in the books!
I am not finding a valid technical angle to tackle this.
apart from that I had another related question:
we can use oledb and connect to ssas2005, right?
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
2) the new jdbc driver for sql 2005, does it allow to connect to ssas 2005?
Thanks once more mosha
Regards
|||No problem with IIS, but the dependency increases and my customer does not want to spend extra on another server
There is no need to spend extra on another server. You can have IIS and Analysis Services server on the same machine.
My customer points out to me that we can do an SOAP over tcp/ip and pass XMLA commands, as printed in the books!
Your customer is wrong. He cannot do that. Microsoft's OLEDB driver and ADOMD.NET can do that, but as I pointed earlier the TCP/IP bindings to XMLA are proprietrary and patent protected.
we can use oledb and connect to ssas2005, right?
Correct
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
Yes
2) the new jdbc driver for sql 2005, does it allow to connect to ssas 2005?
No
|||Hi Mosha,
Thanks a lot :-)
I have been quite a fan of yours!! I am currently in the US, any chance that you are here?
If possible, I was hoping to meet you.
No problem anyway, bye
Thanks again.
Regards
Vijay R
|||
Hi Mosha,
I can java, but donn't like it, therevore i use .Net pure and can communicate with SSAS through XMLA over TCP from my own code without adomd.net and other proprietary junk. Yes I haven't compression and encription, but it runs!!!
What law I break?
|||Hi,
I tried some java code,
that opens a socket connection and sends the xmla in a soap envelope as a string.
but the connections itself in ssas profiler displays as anonymous logon,
the query does not come through to the server at all !
Regards
Vijay R
|||Hi all,
When reading the following statements by Mosha, i was very excited:
we can use oledb and connect to ssas2005, right?
Correct
1) can we pass xmla commands using oledb? command like <Create>, <Alter> etc
Yes
Then I had to ask... How? Do I need to use a different provider / connection string? Do I need to wrap my XMLA in anything? Where can I find further information on this.
Thankyou
Aranda
|||You should send SSPI handshacke info. How to obtain it in java I don't know. In the .Net it is pretty easy.
|||Hi,
can you please explain in detail as to how to send the SSPI handshake info In a .net program?
it would be helpful if you can give a code snippet that expains the procesure.
Regards
|||Hi,
Mosha wrote "as I pointed earlier the TCP/IP bindings to XMLA are proprietrary and patent protected."
Therefore here is not a right place to speak it about.
Regards
|||:-)
So how about this Vladimir Chtepa: vijay_rb@.yahoo.com
in any case, thanks for the interaction.
Regards