see this is the code that is written in c# in visual studio 2005........In visual studio w can connect sql(not mysql) with c# and can even see the sql table visually.........

can we do that similarly in java in netbeans7.0.....

how can i connect sql with java.......do i need to connect the driver externally like that we connect Microsoft Access by connecting the driver through Data Sources (ODBC) in administrator tools in control panel.............

what should be the relevant code for java (the code that is given below is the connection for sql in c#)

String sq1, sq2;
            SqlCommand cmd;
            SqlDataReader rd1;
            SqlConnection con;
            String nam, pas;
            nam = nam.Text;
            pas = pass.Text;
            SqlConnection con;
            password = pass.Text;
                con = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\nidhish\My Documents\Visual Studio 2008\Projects\project\project\data.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True");
                sq1 = "select * from admin where uname='" + usertext.Text + "'";
                cmd1 = new SqlCommand(sq1, con);
                rd1 = cmd1.ExecuteReader();
                if (rd1.Read())
                    name = rd1[0].ToString();
                    passd = rd1[1].ToString();
                if (name == usertext.Text && passd == passtext.Text)
                    MessageBox.Show("Login Success           ", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    mainpage pg=new mainpage();
            catch (Exception) { }

Edited by Jessurider: n/a

5 Years
Discussion Span
Last Post by pbl

Never heard of the SqlConnection() class
usually use

con = DriverManager.getConnection(dbPath + bdName, "sa", "");

And NetBeans has nothing to do with your problem/ NetBeans is just a fancy GUI editor no need to mention it in your topic title

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.