Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- /**
- *
- * @author lab
- */
- public class JavaApplication1 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args)throws Exception {
- // TODO code application logic here
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- System.out.println("Driver Registered ");
- String connectionUrl = "jdbc:sqlserver://192.168.202.177:1433;" +
- "databaseName=Jdbc;user=sa;password=password@123;";
- Connection con = DriverManager.getConnection(connectionUrl);
- String query = "select name from abc";
- Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
- st.execute(query);
- ResultSet rs = st.executeQuery(query);
- int i=1;
- while(rs.next())
- {
- rs.absolute(i);
- System.out.println(rs.getString(1));
- i++;
- }
- System.out.println("done");
- }
- }
Add Comment
Please, Sign In to add comment