Java DB Stored Procedures - javadb

I need a step by step assistance on the technical aspects of the above.
Assuming I have written my Java stored procedure and compiled it, WHERE do I place the class file???
I will use either ij or my java program to create the stored procedure in the database but my question is: where will the class file be?
I am looking at this:
CREATE PROCEDURE procedure-Name(ProcedureParameters)ProcedureElements
Assuming I am executing the above from the ij command line tool, where will the class file with my stored procedures be?
Please provide me with a step by step technical assistance on creating stored procedures in Java DB. Thank you.

I found what I was looking for:
http://docs.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html
Apparently you have to package the class in a jar file and then tell the db where to find it.
It's a long process, am now considering other options like mysql

Related

Oracle Data Modeler generated column name from datamodel too long

I'm trying to create a datamodel in the Oracle Data Modeler module that is available in Oracle SQL Developer. I would like to maintain my data dictionary from this model. To do this (I think) I need a generated DDL file for which the attributes are not longer than 30 characters.
I have just discovered Oracle SQL Developer and am completely new to creating these kind of models. What I have done so far. I have created a logical model and have engineered it to a relational model. From the relational model I can then generate DDL scripts that I can run on the database to make the changes I want.
When doing this I run into a problem. When engineering the logical model to a relational model I can see that the foreign keys I have made become more than 30 characters. This is because it seems to generate the name as (see picture)
From searching it seems you should be able to fix this with naming standard templates. I have looked for this menu option but can't find it. I have found the name abbreviations functionality for which you can upload .csv files but I think this is for something different.
Rightclicking on the logical model in the datamodeler browser view gives me the opportunity to Apply naming standards, but this gives me a message that I should turn off the keep as the name of the originating attribute option (see picture). I have looked for this but can't find this option.
My version of Oracle SQL Developer is 4.1.3.20, Build MAIN-20.78.
Please let me know if my story is not clear. Thanks.
Generated column name
Applying name standards message
You will find the option under Tools/Preferences/Data Modeler/Model/Logical

using EF migrations with SQL Server (Not express/localdb)

New to EF.
Am using code first but created from an initial database.
First issue is when I added a foreign key to the model After executing add-migrations from the console it created migrations to create the entire tables rather than just adding the foreign keys to the existing tables using AddForeignKey(....),
And when I try to update-database it tries to create a localdb database under and i get the error
Directory lookup for the file "C:\src\Project\App_Data\TheDatabase.mdf" failed with the operating system error 2(The system cannot find the file specified.).
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Which kind of makes sense because i'm not using sqlexpress.
It seems as though I need some configuration to coax it into action.
Any useful advice would be welcome.
I found a solution although maybe this is more of a workaround
I did change the connection factory but it did nothing. Still tries to use App_Data folder and looks for an MDF there.
I found a work around though. The package manager lets you override the connection string so i just did that and it works fine.
As for the other part of my question regarding why it was trying to create the tables. What I needed to do first it use the Add-Migration with -IgnoreChanges and update-database will then store an initial blank migration so from then on, any changes you make will be just those incremental ones I was referring to.
Here was the link for that. https://msdn.microsoft.com/en-us/data/dn579398.aspx?f=255&MSPPError=-2147217396
Thanks to those who offered help.
Hope this helps. Basically, EF needs your first snapshot of your database to create the model classes as the initial state, after that you can add migrations.
If it doesn't help, can you post your connection string and number of migrations your have?

Telosys : How can i get database table records in template?

I am using Telosys tools for code generation. It's very nice tool and help me a lot.
But there is one problem, that is, it provides database schema information and i can access in templates (templates are formerly velocity templates), which is good, but how can i get selected entity's data from database? There is no way i can find, by which i can get that selected table data.
Please provide solution if any, or provide alternate way to do it.
Thanking You!
Telosys Tools is designed to retrieve the model from the database,
not the data stored in the tables.
But it allows to create your own specific tooling classes usable
in the templates, so it's possible to create a specific Java Class to retrieve the data from the database.
There's an example of this kind of specific class in the "database-doc" bundle
https://github.com/telosys-tools/database-doc-bundle-TT210 ( in classes folder )
To simplify the loading the simplest way is to create the class in the "default package" (no java package)
NB:
The problem is that the jar containing the JDBC driver
is not accessible by the generator class-loader, so you will have to use a specific class-loader and to connect directly with the JDBC driver.
Here is an example : https://gist.github.com/l-gu/ed0c8726807e5e8dd83a
Don't use it as is (the connection is never closed) but it can be easily adapted.

how to use Store procedure under Entity Framework 3.5

I had imported SP functions with EF model successfully,but couldn't find c# function into context. weird! Anyone had some issue?
Function import not worked for me neither. You may write your execute method or best solution might be (if not neccessary) convert it to Entity Framework 4 and your method will be there for you.
Importing stored procedure through wizard is not enough. You must open model browser and add function import for that stored procedure.

Imported a sproc in EF4 but no code was generated

I have a stored proc in my database and I am using Entity Framework 4 to work with the database from my code. Following instructions for importing a sproc, I was able to add it to my model and import a function to reference it. In the model browser under Function Imports, the stored proc and all its parameters appears. The access says "Public." Yet, I am not able to see it in Intellisense when I go to call it in my context object. When I do a global search on the name of the sproc, I see it appears in 3 places in the EDMX, and once in my calling code, but no code appears to have been generated for it in the Designer.cs file.
I must have missed a step or something, but as I look back through it, it's all pretty simple; I can't see where I went wrong. Has this happened to anyone? How can I troubleshoot?
if you switch to the model browser view on the .edmx file, you can see your imported SProcs under the model store node in the stored procedures folder. You can right-click them there and select "add function import" to generate the execution code in the entity data model's Designer.cs file. Unfortunately, you seem to have to do this import for them individually. If someone knows how to import them all simultaneously, I'd love to know.
Is that what you're looking for?
Take a look at this MSDN thread. On this forum, there is another thread addressing this issue in some way.
In short, it is an EF Designer limitation. You can try writing your own code to call this function, or use third-party designer like Entity Developer.