Guest User

Untitled

a guest
Jun 30th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.87 KB | None | 0 0
  1. package com.nucleus.batch5.brd1;
  2.  
  3. //import java.sql.*;
  4.  
  5.  
  6. public interface ConnectionInterface {
  7.  
  8. public void serverConnection();
  9.  
  10. }
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. package com.nucleus.batch5.brd1;
  18.  
  19. public class Customer {
  20. private int customer_id;
  21. private String customer_code;
  22. private String customer_name;
  23. private String customer_address1;
  24. private String customer_address2;
  25. private int customer_pinCode;
  26. private String email_address;
  27. private String contact_number;
  28. private String primaryConatctPerson;
  29. private String record_status;
  30. private String active_inactiveFlag;
  31. private String create_date;
  32. private String created_by;
  33. private String modified_date;
  34. private String modified_by;
  35. private String authorized_date;
  36. private String authorized_by;
  37.  
  38. public int getCustomer_id() {
  39. return customer_id;
  40. }
  41. public void setCustomer_id(int customer_id) {
  42. this.customer_id = customer_id;
  43. }
  44. public String getCustomer_code() {
  45. return customer_code;
  46. }
  47. public void setCustomer_code(String customer_code) {
  48. this.customer_code = customer_code;
  49. }
  50. public String getCustomer_name() {
  51. return customer_name;
  52. }
  53. public void setCustomer_name(String customer_name) {
  54. this.customer_name = customer_name;
  55. }
  56. public String getCustomer_address1() {
  57. return customer_address1;
  58. }
  59. public void setCustomer_address1(String customer_address1) {
  60. this.customer_address1 = customer_address1;
  61. }
  62. public String getCustomer_address2() {
  63. return customer_address2;
  64. }
  65. public void setCustomer_address2(String customer_address2) {
  66. this.customer_address2 = customer_address2;
  67. }
  68. public int getCustomer_pinCode() {
  69. return customer_pinCode;
  70. }
  71. public void setCustomer_pinCode(int customer_pinCode) {
  72. this.customer_pinCode = customer_pinCode;
  73. }
  74. public String getEmail_address() {
  75. return email_address;
  76. }
  77. public void setEmail_address(String email_address) {
  78. this.email_address = email_address;
  79. }
  80. public String getContact_number() {
  81. return contact_number;
  82. }
  83. public void setContact_number(String contact_number) {
  84. this.contact_number = contact_number;
  85. }
  86. public String getPrimaryConatctPerson() {
  87. return primaryConatctPerson;
  88. }
  89. public void setPrimaryConatctPerson(String primaryConatctPerson) {
  90. this.primaryConatctPerson = primaryConatctPerson;
  91. }
  92. public String getRecord_status() {
  93. return record_status;
  94. }
  95. public void setRecord_status(String record_status) {
  96. this.record_status = record_status;
  97. }
  98. public String getActive_inactiveFlag() {
  99. return active_inactiveFlag;
  100. }
  101. public void setActive_inactiveFlag(String active_inactiveFlag) {
  102. this.active_inactiveFlag = active_inactiveFlag;
  103. }
  104. public String getCreate_date() {
  105. return create_date;
  106. }
  107. public void setCreate_date(String create_date) {
  108. this.create_date = create_date;
  109. }
  110. public String getCreated_by() {
  111. return created_by;
  112. }
  113. public void setCreated_by(String created_by) {
  114. this.created_by = created_by;
  115. }
  116. public String getModified_date() {
  117. return modified_date;
  118. }
  119. public void setModified_date(String modified_date) {
  120. this.modified_date = modified_date;
  121. }
  122. public String getModified_by() {
  123. return modified_by;
  124. }
  125. public void setModified_by(String modified_by) {
  126. this.modified_by = modified_by;
  127. }
  128. public String getAuthorized_date() {
  129. return authorized_date;
  130. }
  131. public void setAuthorized_date(String authorized_date) {
  132. this.authorized_date = authorized_date;
  133. }
  134. public String getAuthorized_by() {
  135. return authorized_by;
  136. }
  137. public void setAuthorized_by(String authorized_by) {
  138. this.authorized_by = authorized_by;
  139. }
  140.  
  141.  
  142.  
  143. }
  144.  
  145.  
  146.  
  147.  
  148. public class DaoInputs {
  149.  
  150.  
  151. Customer customer = new Customer();
  152. Jdbc_conn conn = null;
  153.  
  154. }
  155.  
  156. package com.nucleus.batch5.brd1;
  157.  
  158. import java.io.BufferedReader;
  159. import java.io.File;
  160. import java.io.FileNotFoundException;
  161. import java.io.FileReader;
  162. import java.util.Scanner;
  163.  
  164. public class InputToDb{
  165.  
  166. Scanner scanner=new Scanner(System.in);
  167.  
  168. String path="//D://File1.txt";
  169. public void Reading()
  170. {
  171. /*System.out.println("Enter file name");
  172. String Fname=scanner.next();
  173.  
  174. System.out.println("Enter File Extension");
  175. String Lname = scanner.next();
  176.  
  177.  
  178. while(Lname!="txt")
  179. {
  180. System.out.println("Enter a valid file");
  181. Lname = scanner.next();
  182. }*/
  183.  
  184. try {
  185. BufferedReader reader=new BufferedReader(new FileReader(new File(path)));
  186. } catch (FileNotFoundException e) {
  187. e.printStackTrace();
  188. }
  189.  
  190. String string = null;
  191. while((string=reader.readLine())!=null)
  192. {
  193. String[] Array = new Array[20];
  194. str = string.split("~";)
  195.  
  196. try
  197. {
  198. customer.setCustomer_id(count);
  199. count=count+1;
  200. customer.setCustomer_code(st[0]);
  201. customer.setCustomer_name(st[1]);
  202. customer.setCustomer_address1(st[2]);
  203. customer.setCustomer_address2(st[3]);
  204. customer.setCustomer_pinCode(Integer.parseInt(st[4]));
  205. customer.setEmail_address(st[5]);
  206. customer.setContact_number(st[6]);
  207. customer.setPrimaryConatctPerson(st[7]);
  208. customer.setRecord_status(st[8]);
  209. customer.setActive_inactiveFlag(st[9]);
  210. customer.setCreate_date(st[10]);
  211. customer.setCreated_by(st[11]);
  212. customer.setModified_date(st[12]);
  213. customer.setModified_by(st[13]);
  214. customer.setAuthorized_date(st[14]);
  215. customer.setAuthorized_by(st[15]);
  216. }
  217.  
  218. catch(SQLException e)
  219. {
  220. System.out.println("Sql Exception Detected");
  221. }
  222.  
  223. }
  224.  
  225. }
  226.  
  227.  
  228. }
  229.  
  230. package com.nucleus.batch5.brd1;
  231.  
  232. /*import java.sql.Connection;
  233. import java.sql.DriverManager;*/
  234. import java.sql.SQLException;
  235. import java.sql.*;
  236.  
  237.  
  238. public class Jdbc_conn {
  239.  
  240. String url="jdbc:oracle:thin:@10.1.50.198:1521:orcl";
  241. String username="sh";
  242. String password="sh";
  243. public Jdbc_conn() {
  244. // TODO Auto-generated constructor stub
  245. }
  246.  
  247. public void Connecting() throws SQLException
  248. {
  249. try
  250. {
  251. Class.forName("oracle.jdbc.driver.OracleDriver");
  252. System.out.println("Class Loaded\n");
  253. }
  254. catch(ClassNotFoundException e)
  255. {
  256. e.printStackTrace();
  257. }
  258. try
  259. {
  260. Connection connection=DriverManager.getConnection(url,username,password);
  261. String query="INSERT INTO BRD_P1_BASE VALUES(CUSTOMERCODE,CUSTOMERNAME,CUSTOMERADDRESS1,CUSTOMERADDRESS2," +
  262. "CUSTOMERPINCODE,EMAILADDRESS,CONTACTNUMBER,PRIMARYCONTACTPERSON,RECORDSTATUS,ACTIVEINACTIVEFLAG," +
  263. "CREATEDATE,CREATEDBY,MODIFIEDDATE,MODIFIEDBY,AUTHORIZEDDATE,AUTHORIZEDBY,CUSTOMERID)VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  264.  
  265. PreparedStatement statement = connection.prepareStatement(query);
  266.  
  267. }
  268. catch(SQLException ex)
  269. {
  270. System.out.println("After prepare statement");
  271. ex.printStackTrace();
  272. }
  273.  
  274. }
  275.  
  276.  
  277.  
  278.  
  279.  
  280. }
  281.  
  282.  
  283.  
  284. package com.nucleus.batch5.brd1;
  285.  
  286. //import java.sql.Connection;
  287.  
  288. public class Oracle extends Jdbc_conn implements ConnectionInterface{
  289.  
  290. Jdbc_conn conn=new Jdbc_conn();
  291. @Override
  292. public void serverConnection() {
  293. //Connection connection=null;
  294. try {
  295. conn.Connecting();
  296.  
  297. } catch (Exception e) {
  298. System.out.println("connection faliure");
  299. }
  300. }
  301. }
  302.  
  303. package com.nucleus.batch5.brd1;
  304.  
  305. public class Test_brd {
  306.  
  307.  
  308.  
  309. public static void main(String[] args) {
  310. // TODO Auto-generated method stub
  311.  
  312. }
  313.  
  314. }
Add Comment
Please, Sign In to add comment