xml TO sql

Java program to send data from XML file to SQL Server database

Java program to send data from XML file to SQL Server database import java.sql.*; import java.io.*; import java.util.*; public class xml { public static void main(String…s) { Connection c = null; PreparedStatement ps= null; Statement st = null; ResultSet rs = null; String dbURL=”jdbc:sqlserver://localhost:1433; databaseName

Rollback to Savepoint in Java

JDBC Transaction in Java with Savepoint and Rollback

Rollback to savepoint in Java” Check this simpler example to Rollback a transaction in java import java.sql.*; class SavePointProgram { public static void main(String…ss) { String dbURL=”jdbc:sqlserver://localhost:1433;databaseName=sampledb2″; String user = “sa”; String password = “minisiminoni”; try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); Connection c = DriverManager.getConnection(dbURL, user, password); if

Rollback a transaction in java

Rollback a transaction in Java program

Rollback a transaction in Java import java.sql.*; class Transact2 { public static void main(String…ss) { try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection c = DriverManager.getConnection(“jdbc:odbc:dsn1″, “sa”, “minisiminoni”); if(c !=null) System.out.println(“connected”); Statement s = c.createStatement(); c.setAutoCommit(false); int x = s.executeUpdate(“update employeeDetails set employeename = ‘ritika’ where serialnumber = 3″);

Transaction with commit and autocommit in Java program

Java program to show Transaction with AutoCommit and Commit

Transaction with AutoCommit and Commit Java program: Autocommit(False) to implement atomicity principle of the transaction. import java.sql.*; import java.io.*; class Transact { public static void main(String…ss) { try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection c = DriverManager.getConnection(“jdbc:odbc:dsn1″, “sa”, “minisiminoni”); if(c != null) System.out.println(“Connected to database”); Statement s =

image2

JDBC:Delete data from database

JDBC: Delete data from database using Java Program. Highlight: In this program, we are using System.setProperty in order to directly set the value for drivers instead of using class.forName() for run time Loading. Before Deleting data: After running this program:  import java.sql.*; import java.util.*; class