For those who are working in selenium and related automation tools using Java API are in need of connecting back end databases to verify the values. Here is the high level info.
Required package:
MySQL:
Driver: Class.forName("com.mysql.jdbc.Driver").newInstance();
URL : jdbc:mysql://serverName:port/DBName
Derby:
Driver: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
URL : jdbc:derby:pathToDB:DBName;create=true;
SQL:
Driver: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
URL : jdbc:microsoft:sqlserver://serverName:port/DBName
Refer http://www.linglom.com/2007/03/04/accessing-sql-server-on-netbeans-using-jdbc-part-i-create-a-connection/
Required package:
- import java.sql.*;
- //Initializing the driver for JDBC connection
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- //Creating properties to be passed for connection
- Properties properties = new Properties();
- properties.put("user", "shan");
- properties.put("password", "pass");
- properties.put("characterEncoding", "ISO-8859-1");
- properties.put("useUnicode", "true");
- //actual connection string
- String url = "jdbc:mysql://ServerName:port/DataBaseName";
- //Getting the connection object using properties and url
- Connection conn = DriverManager.getConnection(url, properties);
- //Creating a statement of type CreateStatement
- Statement stmt = conn.createStatement(); //for Insert/Update, create of type conn.executeUpdate
- String sql = "select * from [Sheet1$]";
- RecordSet rs = stmt.executeQuery(sql);
- while(rs.next()){
- username = rs.getString("username");
- password = rs.getString("Password");
- }
MySQL:
Driver: Class.forName("com.mysql.jdbc.Driver").newInstance();
URL : jdbc:mysql://serverName:port/DBName
Derby:
Driver: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
URL : jdbc:derby:pathToDB:DBName;create=true;
SQL:
Driver: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
URL : jdbc:microsoft:sqlserver://serverName:port/DBName
Refer http://www.linglom.com/2007/03/04/accessing-sql-server-on-netbeans-using-jdbc-part-i-create-a-connection/
I am very impressed with your post because this post is very beneficial for me and provide new knowledge to me
ReplyDeleteDriver Automation Tool Crack
WavePad Sound Editor Crack
MovieMator Video Editor Pro Crack
Adobe Acrobat Pro Crack