I am using netbeans IDE 7.1. I am trying to generate entity classes from a database(sql server). I am able to setup the connection to this remote datasource but in the New Entity Classes from database Wizard the tables are not showing up and at the bottom it says select atleast one table.
I could execute queries and browse through the tables from the netbeans databases service.
Can someone help me to fix this..
Thanks
maybe your schema is not selected correctly, check on service windows->database->your connection(the bold schema is a default selected schema) if it wrong, right-click->properties, and change your schema to public, all the tables that you created are here normally
hope useful :)
I faced this issue and the only way I could get it to work was to create a new connection every time. Once i created a new connection it would show me the tables and I could use it, otherwise it would just leave the list empty
In the newer versions of NetBeans if you create a database connection with default schema, it will take mysql as schema name and generate the connection string.
So goto your DB connection in NetBeans and edit your connection url.
Example :
Change
jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=CONVERT_TO_NULL
to
jdbc:mysql://localhost:3306/YOUR_SCHEMA_NAME?zeroDateTimeBehavior=CONVERT_TO_NULL (add your schema name in the connection string and save)
I had to go into Glassfish console and create a special connnection pool and resource. The connection pool had to be res-type="java.sql.Driver" (not datasource). Then when creating my entity, I picked this new resource from the list and it worked, my tables showed up.
Related
I am attempting to create a new database in an existing sql server from code first. I used package manager to enable migrations, add a migration, then update database. The three methods executed without any errors and I got the traditional massages afterwards. However, when I look in either MSSSMS or Server Explorer I don’t see the database. I tried re-running the update database command and got the migration has already been applied. Any suggestions?
Update:
I've figured out that the project is adding the database to localdb. However, I have a connection string in the app.config file.
Probable causes are:
the database was never created
you use a login that can't see the database. Using Windows authentication/sa might allow you to see it and create user mappings for other logins.
you have multiple instances of sql running and you're connecting to the default instance while the database what created on a named instance
you accidentally created the database on another server
you connect to master by default with your software and instead of creating a database the database structure was created in the system database master
I've been working with MS sql for more than a decade and have struggled with issues like these, but in the end I could always explain what happened; if SQL returns it executed a query succesfully id did.
I've been trying for a while to connect the database to visualstudio.net and it just doesn't work.
First I made the database and made everything I needed there and when I tried connecting it in visual.net through datagridview (trying to get it displayed there) it only gives me access to the "System databases" in which I can't make a database.
After that I decided to make the tables under the "master" database to see if that worked and yeah I can select the database and everything but it says it's empty when I know it's not. It says it has no tables when I've checked multiple times and saw the tables I've created there.
I would appreciate some help to either be able to get for visual to accept a database I make (to be able to automatically detect it once I enter the server name) or to see how can I use the master one properly.
You can add a data source to your project and it will be able to connect to the user databases. Also, it is highly inadvisable to create any user objects in the master database.
master database is a system database and you should not create user objects in the system database. In the connection string, provide the user database name explicitly. If you dont provide the database name, it defaults to master database.
Refer to connection strings for Sql Server for providing the right connection string for SQL Server in .net.
I am using Visual Studio 2012 and an SQL Server Database.
At first, my program loads all the tables as well as views but when I try to do some modifications to the database schema (e.g. add some views) the changes are not reflected when I deleted the connection in the Solution Explorer-Model and then reconnect it.
I tried to delete the connection again, load the database and reconnect, but still, I get same results.
Why is this so? Any idea?
First, I make a database by clicking App_Data and add new Item. I add SQL Server Database. So that's why the entities has a .mdf extension.
Next, I add new tables on the database by right clicking the "Tables" and Add new Table on it. Insert new columns as well as the keys.
Then, I connect to the database by Right clicking Model in the Solution Explorer and add ADO.Net Entity Model. I used the Database.mdf for my connection. After that, it automatically generates the connection string in the web.config as well as the diagram.
Usually, when I made some changes in the database, I deleted the connection and reconnect again. Before I had no problems with it. The changes were seen upon reconnection but this time when I tried using with another app, I'm wondering why the modifications were not seen. I tried many times to connect and delete again the database but still nothing works.
As I understand you, you works directly with .mdf file. Consecuently, each time when you starts your application it copies into Debug folder and if you work with this local copy (it depends on your connection string in App.config) you change data exactly in Debug folder. So, each time you erase your changes when application starts, try to changes your connnection string.
I am using a HSQL driver to connect to my database. I am able to connect without any errors but I can't see any of my tables in the table tree under public. I am able to create new tables which do appear, but I can't see the already created ones. Also when I check the .script file I can't see the new tables. Something strange is going on but I can’t work out what.
Anyone able to help.
I've worked it out now. It was the format of the connect string for HSQL.
I needed to add :file: in the string like this... jdbc:hsqldb:file:
Also I was using .script at the end of the file name, like this jdbc:hsqldb:.script
This was creating temp files in the format .script.lck .script.log etc.
Dropping the .script at the end of the file name opened up the database and allowed me to see the tables. Now my problem is I can't get any updates to commit. Updates happen with no errors in the console. But when I close the file and check the .script file the data is the same. Permissions I guess.
Only posting this answer to help others that might get stuck at the same point.
Try here:
How can I list all tables in a database with Squirrel SQL?
Where most of us fails is to choose the right schema in the Catalog dropdown. (Just above the Objects tab). But there are other ideas if you follow the related question.
I'm working an OCA application based on a SQL server db and a SQL CE client db. Each user has there own table in the on the SQL server db. Each user's table has the same schema but can have different data. I'd like to make the synctable name to be dynamically set in the client application based on the their SQL server DB table name (which is set as userID + "__usersdatatable").
The sync service runs without problems when I don't attempt to change anything. My latest idea was to change SyncTable.TableName = "jsmith_usersdatatable"; in the LocalDataCache1SyncAgent.cs in the oninitialized() method. However, I get the following error:
"Unable to initialize the client database, because the schema for table 'zlentz_GOBOS'
could not be retrieved by the GetSchema() method of DbServerSyncProvider. Make sure
that you can establish a connection to the client database and that either the
SelectIncrementalInsertsCommand property or the SelectIncrementalUpdatesCommand
property of the SyncAdapter is specified correctly."
In short the idea is that each OCA will need to sync to a different table (bidirectional).
I'm obviously no SQL or sync Services expert so advice would helpful. :)
Thanks in advanced!
After learning more about the Sync Framework it was apparent that I needed to work outside the wizard.
For future viewers the following link was very helpful:
http://www.codeproject.com/Articles/18027/Take-Data-Offline-Using-Microsoft-Synchronization