| | |
Test JDBC drivers
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
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)); } }
Similar Threads
- Application can't find JDBC Drivers (Java)
- Drivers test! (Geeks' Lounge)
- Test-Typing Vs. Test-Speaking (IT Professionals' Lounge)
- What is the difference between jdbc odbc jdbc-odbc (JSP)
- how to install nvidia drivers and soundblaster drivers on mandrake (*nix Software)
| Thread Tools | Search this Thread |
Tag cloud for Java
addressbook android api apple applet application arguments array arrays automation binary bluetooth button calculator chat class classes client code columns component converter database draw eclipse error errors event exception file fractal ftp game givemetehcodez graphics gridlayout gui helpwithhomework html ide image inetaddress input integer j2me japplet java javaprojects jme jmf jni jpanel julia link linux list loop map method methods midlethttpconnection mobile netbeans newbie number objects openjavafx oracle php print problem program programming project projects recursion rim scanner screen server set signing size smart sms socket sort sql storm string support swing test threads time tree unlimited variablebinding webservices windows



