Create a class with methods which starts and stops the server and test it as plain Java Application with main().
Once you got that work, you just have to let the button use this class and invoke the method accordingly.
Read this FAQ. Your sore fingers are causing trouble for other readers, I am afraid.
Thabo Matjuda wrote:Thanks Man. I wil look into it, ryt nw its 4am where i stay. My eyes are painful together with Fingers too. Thanks, i wil cme again when I get stuck.
Satya Maheshwari wrote:Runtime.exec is a good idea but may compromise the portability of the application. Is there a java way to start the server i.e. can the server be started by running a class in JVM.
Needing to run SQL Server as part of the application has already compromised the portability of the application; its Windows only. Which makes me wonder why you would use Java to control SQL Server at all? SQL Server runs as a service which will run at startup by default. Why not just trust the database will be running? Or even better, why not host the database on a server and manage it yourself using the out the box tools?
If all you need to do is connect to the (already running) server that is just basic JDBC. The JDBC tutorial and our own JDBC FAQs are good places to get an understanding of how to do that.