Tự động start server trong Netbeans

Em đang học lập trình cơ sở dữ liệu java với Derby trên Netbeans. Nhưng mỗi lần khởi động Netbeans là phải Start Server. Có ai chỉ cho em cách tự động Start Server khi khởi động NB được không ạ, em cảm ơn

Có 2 cách để làm việc này.

Em có thể viết 1 file batch và chạy mỗi lần chạy netbean, tuy nhiên vẫn phải click chuột và đợi. Tiện hơn nữa có thể viết file auto run cái batch này khi khởi động cùng windows

Nội dung file batch

PATH C:\Program Files\Java\jdk1.8.0_25\db\bin;%PATH%
startNetworkServer

Autorun sample

call startNetworkServer.bat

Cách 2 là dùng AlwaysUp để tạo services cho Derby Network Server như windows services.msc

1 : Download and install AlwaysUp
2: Khởi động AlwaysUp.
3: Chọn Application > Add để mở cửa sổ Add Application:


4: On the General tab:

In the Application field, enter the full path to the batch file that starts Derby Network Server, startNetworkServer.bat. Since we have placed Derby in C:\Derby, this is

C:\Derby\bin\startNetworkServer.bat
In the Name field, enter the name that you will call the application in AlwaysUp. We have specified Derby Network Server but you can specify another name if you like.

5: Click over to the Logon tab and enter the user name and password of the account in which you installed Derby. Derby should run in this account so that it can find its settings, java, etc.

6: Click over to the Startup tab and check the Ensure that the Windows Networking components have started box. This informs AlwaysUp that Derby needs the network to do its work.

7: It is best to use stop Derby by running the stopNetworkServer.bat script. To set that up, move to the Extras tab, check the Use this special command to stop the application box and fill in the path to the batch file in Derby’s bin folder.

8: Click the Save >> button. In a couple of seconds, an application called Derby Network Server will show up in the AlwaysUp window. It is not yet running though.

9: To start Derby from AlwaysUp, choose Application > Start “Derby Network Server”.

10: On Windows 8, 7, Vista, Server 2012 or 2008, Derby will be running in Session 0. Select Tools > Switch to Session 0 to transport yourself to the austere Session 0 desktop where the Derby Network Server console will be visible:

That’s it! Next time your computer boots, Apache Derby Network Server will start up immediately, without anyone needing to log on. Please restart your PC now and test that Derby works as expected after Windows comes back to life.

And please feel free to edit Derby in AlwaysUp to check out the many other settings that may be appropriate for your environment. For example, send email alerts if it stops, hide the console, boost Derby’s priority, etc.

4 Likes

Em cảm ơn ạ. Anh cho em hỏi thêm nếu em dùng CSDL Access em bỏ vào folder src thì làm sao để em lấy url của file csdl đó để cho vào chương trình ?

Em lập topic khác nhé

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?