C#からJavaへマイグレーションを行っているのですが、
C#で実装されている関数をJavaで代替する方法が分からなく、
ご教授頂ければと思います。
よろしければ、すべてJavaに直した場合を見たいのですが、
SqlCommandだけでも教えていただけると助かります。
初歩的な質問ですみません。
- DBAccess.cs
C#
1public DataTable getMstDevice(int logger_id, string data_type) 2 { 3 DataTable table = new DataTable(); 4 SqlConnection conn = new SqlConnection(); 5 SqlCommand command = new SqlCommand(); 6 7 try 8 { 9 // DEVICEを取得 10 conn.ConnectionString = Configs.ConnectionStringSensor3; 11 conn.Open(); 12 13 command.Connection = conn; 14 if (data_type == "logging") 15 { 16 command.CommandText = 17 ""; 18 } 19 else if (data_type == "counter") 20 { 21 command.CommandText = 22 ""; 23 } 24 command.Parameters.Add(new SqlParameter("logger_id", SqlDbType.Int)); 25 command.Parameters["logger_id"].Value = logger_id; 26 27 SqlDataAdapter ad = new SqlDataAdapter(command); 28 ad.Fill(table); 29 30 conn.Close(); 31 } 32 catch (Exception ex) 33 { 34 _ilog.Error("iService", ex); 35 } 36 finally 37 { 38 if (conn.State == ConnectionState.Open) 39 { 40 conn.Close(); 41 } 42 } 43 return table; 44 }
- Config.cs
C#
1public static string ConnectionStringSensor3 2 { 3 get 4 { 5 if (_connectionStringSensor3 == null) 6 { 7 _connectionStringSensor3 = ConfigurationSettings.AppSettings["ConnectionStringSensor3"].ToString(); 8 } 9 10 return _connectionStringSensor3; 11 } 12 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/07/27 03:43