khaled_jawaher -2 Junior Poster in Training

I want to use java to access microsoft sql server express remotely.i have allow remote connection in the database that i have.and i allow port 1433 through firewall.


the code is:

import java.sql.*; 
import java.lang.*;
public class Jdbcconn 
{
public static void main(String[] args) 
{ 
try 
{ 
//load the driver class 
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection
("jdbc:sqlserver://localhost:1433;DatabaseName=employee;user=sa;password=moujtaba"); 
Statement insert=conn.createStatement();
insert.executeUpdate("insert into person(id,name) values (2,'ali')");
}catch(ClassNotFoundException cnfe) 
{ 
System.err.println(cnfe); 
} 
catch (SQLException sqle) 
{ 
System.err.println(sqle); 
} 
} 
}

the code is working well in my pc,i want to transform it from another pc bcs my goal is
to access my database remotely.
i have 2 questions:
1.is it possible to use DYNDNS service to substitute localhost colored above,bcs i have dynamic ip address.
2.i am using iis,where should i put my database,for ex if it is in c:\program files,what should i do?
best regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.