Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nucleus.batch5.brd1;
- //import java.sql.*;
- public interface ConnectionInterface {
- public void serverConnection();
- }
- package com.nucleus.batch5.brd1;
- public class Customer {
- private int customer_id;
- private String customer_code;
- private String customer_name;
- private String customer_address1;
- private String customer_address2;
- private int customer_pinCode;
- private String email_address;
- private String contact_number;
- private String primaryConatctPerson;
- private String record_status;
- private String active_inactiveFlag;
- private String create_date;
- private String created_by;
- private String modified_date;
- private String modified_by;
- private String authorized_date;
- private String authorized_by;
- public int getCustomer_id() {
- return customer_id;
- }
- public void setCustomer_id(int customer_id) {
- this.customer_id = customer_id;
- }
- public String getCustomer_code() {
- return customer_code;
- }
- public void setCustomer_code(String customer_code) {
- this.customer_code = customer_code;
- }
- public String getCustomer_name() {
- return customer_name;
- }
- public void setCustomer_name(String customer_name) {
- this.customer_name = customer_name;
- }
- public String getCustomer_address1() {
- return customer_address1;
- }
- public void setCustomer_address1(String customer_address1) {
- this.customer_address1 = customer_address1;
- }
- public String getCustomer_address2() {
- return customer_address2;
- }
- public void setCustomer_address2(String customer_address2) {
- this.customer_address2 = customer_address2;
- }
- public int getCustomer_pinCode() {
- return customer_pinCode;
- }
- public void setCustomer_pinCode(int customer_pinCode) {
- this.customer_pinCode = customer_pinCode;
- }
- public String getEmail_address() {
- return email_address;
- }
- public void setEmail_address(String email_address) {
- this.email_address = email_address;
- }
- public String getContact_number() {
- return contact_number;
- }
- public void setContact_number(String contact_number) {
- this.contact_number = contact_number;
- }
- public String getPrimaryConatctPerson() {
- return primaryConatctPerson;
- }
- public void setPrimaryConatctPerson(String primaryConatctPerson) {
- this.primaryConatctPerson = primaryConatctPerson;
- }
- public String getRecord_status() {
- return record_status;
- }
- public void setRecord_status(String record_status) {
- this.record_status = record_status;
- }
- public String getActive_inactiveFlag() {
- return active_inactiveFlag;
- }
- public void setActive_inactiveFlag(String active_inactiveFlag) {
- this.active_inactiveFlag = active_inactiveFlag;
- }
- public String getCreate_date() {
- return create_date;
- }
- public void setCreate_date(String create_date) {
- this.create_date = create_date;
- }
- public String getCreated_by() {
- return created_by;
- }
- public void setCreated_by(String created_by) {
- this.created_by = created_by;
- }
- public String getModified_date() {
- return modified_date;
- }
- public void setModified_date(String modified_date) {
- this.modified_date = modified_date;
- }
- public String getModified_by() {
- return modified_by;
- }
- public void setModified_by(String modified_by) {
- this.modified_by = modified_by;
- }
- public String getAuthorized_date() {
- return authorized_date;
- }
- public void setAuthorized_date(String authorized_date) {
- this.authorized_date = authorized_date;
- }
- public String getAuthorized_by() {
- return authorized_by;
- }
- public void setAuthorized_by(String authorized_by) {
- this.authorized_by = authorized_by;
- }
- }
- public class DaoInputs {
- Customer customer = new Customer();
- Jdbc_conn conn = null;
- }
- package com.nucleus.batch5.brd1;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.util.Scanner;
- public class InputToDb{
- Scanner scanner=new Scanner(System.in);
- String path="//D://File1.txt";
- public void Reading()
- {
- /*System.out.println("Enter file name");
- String Fname=scanner.next();
- System.out.println("Enter File Extension");
- String Lname = scanner.next();
- while(Lname!="txt")
- {
- System.out.println("Enter a valid file");
- Lname = scanner.next();
- }*/
- try {
- BufferedReader reader=new BufferedReader(new FileReader(new File(path)));
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- String string = null;
- while((string=reader.readLine())!=null)
- {
- String[] Array = new Array[20];
- str = string.split("~";)
- try
- {
- customer.setCustomer_id(count);
- count=count+1;
- customer.setCustomer_code(st[0]);
- customer.setCustomer_name(st[1]);
- customer.setCustomer_address1(st[2]);
- customer.setCustomer_address2(st[3]);
- customer.setCustomer_pinCode(Integer.parseInt(st[4]));
- customer.setEmail_address(st[5]);
- customer.setContact_number(st[6]);
- customer.setPrimaryConatctPerson(st[7]);
- customer.setRecord_status(st[8]);
- customer.setActive_inactiveFlag(st[9]);
- customer.setCreate_date(st[10]);
- customer.setCreated_by(st[11]);
- customer.setModified_date(st[12]);
- customer.setModified_by(st[13]);
- customer.setAuthorized_date(st[14]);
- customer.setAuthorized_by(st[15]);
- }
- catch(SQLException e)
- {
- System.out.println("Sql Exception Detected");
- }
- }
- }
- }
- package com.nucleus.batch5.brd1;
- /*import java.sql.Connection;
- import java.sql.DriverManager;*/
- import java.sql.SQLException;
- import java.sql.*;
- public class Jdbc_conn {
- String url="jdbc:oracle:thin:@10.1.50.198:1521:orcl";
- String username="sh";
- String password="sh";
- public Jdbc_conn() {
- // TODO Auto-generated constructor stub
- }
- public void Connecting() throws SQLException
- {
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- System.out.println("Class Loaded\n");
- }
- catch(ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- try
- {
- Connection connection=DriverManager.getConnection(url,username,password);
- String query="INSERT INTO BRD_P1_BASE VALUES(CUSTOMERCODE,CUSTOMERNAME,CUSTOMERADDRESS1,CUSTOMERADDRESS2," +
- "CUSTOMERPINCODE,EMAILADDRESS,CONTACTNUMBER,PRIMARYCONTACTPERSON,RECORDSTATUS,ACTIVEINACTIVEFLAG," +
- "CREATEDATE,CREATEDBY,MODIFIEDDATE,MODIFIEDBY,AUTHORIZEDDATE,AUTHORIZEDBY,CUSTOMERID)VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- PreparedStatement statement = connection.prepareStatement(query);
- }
- catch(SQLException ex)
- {
- System.out.println("After prepare statement");
- ex.printStackTrace();
- }
- }
- }
- package com.nucleus.batch5.brd1;
- //import java.sql.Connection;
- public class Oracle extends Jdbc_conn implements ConnectionInterface{
- Jdbc_conn conn=new Jdbc_conn();
- @Override
- public void serverConnection() {
- //Connection connection=null;
- try {
- conn.Connecting();
- } catch (Exception e) {
- System.out.println("connection faliure");
- }
- }
- }
- package com.nucleus.batch5.brd1;
- public class Test_brd {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- }
- }
Add Comment
Please, Sign In to add comment