Re: Using JDBC for SQLExpress



Couple of setting changes fixed this. The TCP/IP protocol was set to use
dynamic port (I'm not using the SQL Browser yet). I changed it to use a
static port and then using the 'SQL Server Surface Area Configuration' I
enabled TCP/IP for local and remote connection.

I had to specify the port number in the connection string and the program's
working now.

Thanks for your help.

"Angel Saenz-Badillos[MS]" wrote:

> The exception that you are seeing indicates that we were not able to get the
> portnumber for the SQLEXPRESS instance. We retrieve the port number by
> sending a DatagramPacket to port 1433 of the server you specified, for some
> reason this is taking longer than 5000ms to complete.
>
> Can you think of anythign that may be affecting this? my first guess would
> be that the SQL Server Browser is not running, you can check the status of
> this service in the SQL Server Configuration Manager that installed with Sql
> Express under SQL Server 2005 Services -> SQL Server Browser->start.
>
> If this is not the problem my second guess would be an issue with a
> firewall.
>
> --
> Angel Saenz-Badillos [MS] DataWorks
> This posting is provided "AS IS", with no warranties, and confers no
> rights.Please do not send email directly to this alias.
> This alias is for newsgroup purposes only.
> I am now blogging: http://weblogs.asp.net/angelsb/
>
>
>
>
> "Chandresh" <Chandresh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:2570580E-1DFE-43A3-8B59-9049531ADB04@xxxxxxxxxxxxxxxx
> > Thanks for the response. That did not work. I tried out the sanple code
> > and I
> > get the following exception:
> >
> > Failed Logon:com.microsoft.sqlserver.jdbc.SQLServerException: Failed
> > connection to named instance [sqlexpress]
> > [java.net.SocketTimeoutException:
> > Receive timed out] Error Code = 0
> > com.microsoft.sqlserver.jdbc.SQLServerException: Failed
> > Logon:com.microsoft.sqlserver.jdbc.SQLServerException: Failed connection
> > to
> > named instance [sqlexpress] [java.net.SocketTimeoutException: Receive
> > timed
> > out]
> > at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown
> > Source)
> > at java.sql.DriverManager.getConnection(DriverManager.java:525)
> > at java.sql.DriverManager.getConnection(DriverManager.java:193)
> > at SQLXJdbcTest.main(SQLXJdbcTest.java:10)
> >
> >
> > "Angel Saenz-Badillos[MS]" wrote:
> >
> >> There are a couple of things to keep in mind when using Sql Express with
> >> the
> >> JDBC driver:
> >> · You need to enable mixed mode security when you install the
> >> server
> >> so that you can connect using user name and password.
> >> · The JDBC provider only works with the TCP/IP protocol which is
> >> disabled by default on Sql Express. You need to enable the TCP/IP
> >> Protocol
> >> from the SQL Server Configuration Manager that ships with SqlExpress and
> >> re-start the server. Look under SQL Server 2005 Network Configuration ->
> >> Protocols for SQLEXPRESS-> TCP/IP->Enable.
> >>
> >> Once you have set up Sql Express accordingly you can connect like this:
> >>
> >> import java.sql.*;
> >>
> >> public class test{
> >> public static void main(String[] args) {
> >> try{
> >>
> >> java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> >> Connection c =
> >> java.sql.DriverManager.getConnection("jdbc:sqlserver://localhost\\SQLEXPRESS;user=myuser;password=mypass;");
> >> System.out.println("Connected!");
> >> }catch(Exception ex){
> >> ex.printStackTrace();
> >> }
> >> }
> >> }
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Angel Saenz-Badillos [MS] DataWorks
> >> This posting is provided "AS IS", with no warranties, and confers no
> >> rights.Please do not send email directly to this alias.
> >> This alias is for newsgroup purposes only.
> >> I am now blogging: http://weblogs.asp.net/angelsb/
> >>
> >>
> >>
> >>
> >> "Chandresh" <Chandresh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:F7F63D04-20D7-4194-9CD3-18310E3EE941@xxxxxxxxxxxxxxxx
> >> > Has anyone used the JDBC driver for SQL Server 2005 to access a
> >> > SQLExpress
> >> > database? Could you please share how did you configure SQLExpress to be
> >> > able
> >> > to do this? What connection string did you use?
> >>
> >>
> >>
>
>
>
.



Relevant Pages

  • Re: Named Instance auch direkt anprechbar?
    ... Ich kann mich zwar nicht erinnern, wann ich es das letzte Mal so gemacht habe, aber Du könntest auch einen Alias (in der SQL Server Clientkonfiguration) einrichten, der auf die IP-Adresse und Port der SQL Server-Cluster-IP-Adresse zeigt. ... Deinen SQL Server kannst Du durchaus mehrfach ansprechen. ... SQLClusterE ist der SQL Server Clustername und sollte beim Zugriff verwendet werden. ...
    (microsoft.public.de.sqlserver)
  • Re: hack using xp_cmdshell
    ... > Fortunately 14 years of SQL experience, and a little common sense, would ... > should run it on a different port and just have my developers connect to ... Tibor Karaszi, SQL Server MVP ... >> install SQL Server in Windows Only mode and then Switch down to Mixed ...
    (microsoft.public.sqlserver.server)
  • Re: connecting to sql svr express over internet
    ... also add the prefix tcp: to specify the TCP protocol (or np: for named ... of the server and the protocol and the port to be used. ... See SQL Server Configuration Manager | SQL Native Client Configuration | ... I have Sql Server 2005 Express edition installed on a server. ...
    (microsoft.public.sqlserver.server)
  • Re: Getting an absolutely up to date version of MSDE
    ... The real reason for updating is that I have online SQL Server ... >> Enterprise Manager connection does not now work (has worked splendidly ... >dynamically assigned port (actually letting the remote MDAC client stack be ...
    (microsoft.public.sqlserver.msde)
  • Re: Named Instance auch direkt anprechbar?
    ... Ich kann mich zwar nicht erinnern, wann ich es das letzte Mal so gemacht habe, aber Du könntest auch einen Alias (in der SQL Server Clientkonfiguration) einrichten, der auf die IP-Adresse und Port der SQL Server-Cluster-IP-Adresse zeigt. ... SQLClusterE ist der SQL Server Clustername und sollte beim Zugriff verwendet werden. ...
    (microsoft.public.de.sqlserver)

Loading