•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 427,940 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,656 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
import java.sql.*; public class TestJdbc { static String sql = "select * from test_table where column1 = ?"; static String userId = "userid"; static String password = "password"; static String dbServer = "dbserver"; static String dbName = "database"; public static void main(String[] args) throws Exception { testMSDriver(); } private static void testMSDriver() throws Exception { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+ dbServer +";SendStringParametersAsUnicode=false;dataSourceName=SQL2000JDBC;databaseName="+ dbName +";serverName="+ dbServer +";selectMethod=cursor", userId, password); long start = System.currentTimeMillis(); PreparedStatement stmt = conn.prepareStatement(sql); stmt.setString(1, "string1"); ResultSet rs = stmt.executeQuery(); while (rs.next()) { // System.out.println("Result: " + rs.getString(1)); } conn.close(); System.out.println("Elapsed time for MS driver: " + (System.currentTimeMillis() - start)); } }
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)