import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import net.sourceforge.jtds.jdbcx.JtdsDataSource; public class JtdsExample { private static JtdsDataSource dataSource; public static void main(String[] args) { Properties props = new Properties(); props.setProperty("user", "your_username"); props.setProperty("password", "your_password"); props.setProperty("serverName", "your_server_name"); props.setProperty("portNumber", "your_port_number"); props.setProperty("databaseName", "your_database_name"); dataSource = new JtdsDataSource(); dataSource.setDataSourceProperties(props); try { Connection connection = dataSource.getConnection(); // ... connection.close(); } catch (SQLException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文