0

I currently have a java application that I need to connect and write to a SQLEXPRESS instance of the SQLserver DB, at the moment my code will connect to the DB, but only if I open the SQL server config manager and manually enable the TCP/IP protocol,set the port to 1433 and then restart the server. The following link describes what i am talking about https://dzone.com/articles/connecting-sql-server-java this.

I want to distribute my application to users, but I don't want the users to have to manually set this themselves I want my java code to do it for them, is this possible to do in java?

noobCoder
  • 370
  • 1
  • 8
  • 18
  • Probably somehow but why not choose a different database that is simpler to include? http://stackoverflow.com/questions/11639256/is-sqlite-the-most-appropriate-thing-to-use-for-an-embedded-database – zapl Jun 03 '16 at 17:18
  • I can't, the customers will always have a sqlserver database, so my application needs to interact with it. – noobCoder Jun 03 '16 at 17:49
  • Who performs the installation of SQL Server Express? You or your users? – Dave Mason Jun 03 '16 at 18:13
  • 1
    Idk if that's still applicable but http://stackoverflow.com/questions/9138172/enable-tcp-ip-remote-connections-to-sql-server-express-already-installed-databas could work for you. Would be just some windows install script to run rather than doing it in java. Java has not much operating specific features because it tries not to, that makes it hard to do those very os specific tasks with it. – zapl Jun 03 '16 at 18:26
  • The users will perform the installation themselves, and then at some point in time they will down load my application, and my application will need to interact with there database. – noobCoder Jun 03 '16 at 18:36
  • What happens if your users have databases for other applications on the SQL instance? Will your changes to the SQL configuration affect them? You should not assume that your app will be running on a dedicated instance of SQL. Just some food for thought... – Dave Mason Jun 03 '16 at 19:54
  • On a side note, I don't get a warm and fuzzy from that article you referenced. The author's solution is not what I would have done. Check out MSDN's [Building the Connection URL](https://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) article for jdbc connectivity to SQL Server. Note that the port number is optional. If you don't specify the port number, the connection is attempted on 1433 for a default SQL instance. – Dave Mason Jun 03 '16 at 20:11
  • 1
    For a named instance, jdbc should communicate with the SQL host's "SQL Browser Service" over UDP port 1434. The Browser Service will then determine which port the SQL instance name is running on and return the port number to the java app. The app then connects automatically over that port number. This is how dynamic port numbers work in SQL. Did all of that make sense? – Dave Mason Jun 03 '16 at 20:14
  • 1
    TCP/IP is another issue. If your java app resides on the SQL host, it should be able to communicate with SQL server via Shared Memory. TCP/IP won't need to be explicitly enabled. If your java app resides remotely, then you will need some other protocol besides Shared Memory enabled (ie TCP/IP...or Named Pipes). – Dave Mason Jun 03 '16 at 20:16
  • ya the link i put up isn't great, just handy since it was a brief example of what i was doing, Ya that makes perfect sense thanks for the help. – noobCoder Jun 03 '16 at 20:25

0 Answers0