1
I want to structure an INSERT using JAVA in the same way that INSERT is structured in VB .NET. It follows how the code is in VB . NET:
Const _spName = "dbo.MEJT_SP_CAD_PRODUTOS"
Public Function IncluirProduto(produto As MEJTProdutoEnt) As Integer
Dim _nomeServidor As String = String.Empty
Dim param(6) As SqlParameter
Try
param(0) = New SqlParameter("@MODO", "INSERIR")
param(1) = New SqlParameter("@Nome_Produto", produto.Nome)
param(2) = New SqlParameter("@Fornecedor", produto.Fornecedor)
param(3) = New SqlParameter("@Codigo_Barras", produto.CodBarras)
param(4) = New SqlParameter("@Marca", produto.Marca)
param(5) = New SqlParameter("@Preco_Compra", produto.PrecoCompra)
param(6) = New SqlParameter("@Categoria", produto.Categoria)
produto.ID_Produto = Convert.ToInt32(MyBase.ExecuteScalar(_spName, param))
Return produto.ID_Produto
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
I researched a little how I can use this same structure in JAVA and I saw that they use Callablestatement, but in a different way. I wonder if you can use this structure. Could you indicate what I can search to try to mount this way.
Thank you for your cooperation.
Thank you very much!!
– DSCM
@Danielmoura if the answer has solved your problem don’t forget to click next to it to mark it as chosen so it can serve other people with similar doubts.
– Sorack