Question

I have two questions regarding implementation of a small Database Application generated by me in JAVA using Netbeans 7.2 for school.

  1. I am using MS SQL Server 2008 with java using Netbeans 7.2. if i will implement my Database Application on my client computer do i need to install MS SQL Server 2008 on my client computer for using a small Database Application.

  2. The database i have created in MS SQL Server 2008 for my a small Database Application can i embedded my database file in my Database Application using Netbeans 7.2 because the database file i have created is on my computer. So how i will implement my a small Database Application on my client computer with database file without installation MS SQL Server 2008 on my client computer.

My Database Application development tools:

  1. Language JAVA
  2. IDE Netbeans 7.2
  3. Database MS SQL Server 2008
  4. Windows 7
  5. Jasper iReport

My Database Application Java database connectivity class file source code so how i can convert Java database connectivity source code for embedded database source code because Java Driver Manager using current my computer MS SQL Server 2008 instance name with username and Password.

import java.sql.*;
import javax.swing.*;

public class Conect {
    Connection conn=null;

    public static Connection Connector()
    {
    try 
        {
         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
         Connection conn = DriverManager.getConnection("jdbc:sqlserver://STAR;databaseName=test","me","778899");
        return conn;
        }

         catch (Exception exp)
            {
            JOptionPane.showMessageDialog(null, exp);
            }
        return null;
     }
}
Was it helpful?

Solution

If you have a "desktop" app that needs a database (i.e. it needs to persist a dataset that's not shared between users), use an embedded database engine. For Java, H2 is a good choice.

OTHER TIPS

  1. Probably yes, unless your client can access SQL Server running on a remote machine.
  2. NetBeans is an IDE. It shouldn't have much to do with how you implement and deploy an application. It's certainly not necessary to deploy an app. If you rely on it too much, it's likely you'll have issues when it's out of the picture.

If you need a database for a client, you can go with Hypersonic (as recommended by Millimoose) or Derby, which is already part of JDK 7 and higher, or SQLLite. There are lots of choices for embedded, local database besides SQL Server. The good news is that your code only needs to change the connection URL and JDBC driver JAR, as long as the SQL is generic enough.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top