title: jdbc: " Invalid object name '[table name]'."
body: <p>So for the past few hours i've been trying to set up a database and to then use the database as DataSource in a Java Servlet (I'm using Netbeans). For some reason I keep getting the error "Invalid object name 'Accounts" when I try to execute the statement "insert into Accounts(Email, Hash, Salt) values(xyz, xyz, xyz). I have no clue why this keeps happening, because I definitely have the table in my database. </p>
  
  <p>I use SQL Server 2016.</p>
  
  <p>My context.xml file is set up as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Context antiJARLocking="true" path="/opdracht2"&gt;
    &lt;Resource auth="Container" 
              driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
              logAbandoned="true" 
              maxActive="8"
              maxIdle="4"
              name="jdbc/H4O"
              password="secret" 
              removeAbandoned="true" 
              removeAbandonedTimeout="60"
              type="javax.sql.DataSource" 
              url="jdbc:sqlserver://DESKTOP-PS13CKQ;integratedSecurity=true"
              username="DESKTOP-PS13CKQ\MemeMeister"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>When I run the following code to see what tables there are:</p>
  
  <pre><code>Connection connection;
  connection = dataSource.getConnection();
  DatabaseMetaData md = connection.getMetaData();
  ResultSet rs = md.getTables(null, null, "%", null);
  ResultSet rs2 = md.getSchemas();
  while (rs.next()) {
      System.out.println("rs.getString(3));
  }
  System.out.println("------Schemas-----");
  while (rs2.next()) {
      System.out.println(
      rs2.getString("TABLE_SCHEM") 
      + ", "+rs2.getString("TABLE_CATALOG"));
  }
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>MSreplication_options
  spt_fallback_db
  spt_fallback_dev
  spt_fallback_usg
  spt_monitor
  trace_xe_action_map
  trace_xe_event_map
  spt_values
  CHECK_CONSTRAINTS
  COLUMN_DOMAIN_USAGE
  COLUMN_PRIVILEGES
  COLUMNS
  CONSTRAINT_COLUMN_USAGE
  CONSTRAINT_TABLE_USAGE
  DOMAIN_CONSTRAINTS
  DOMAINS
  KEY_COLUMN_USAGE
  PARAMETERS
  REFERENTIAL_CONSTRAINTS
  ROUTINE_COLUMNS
  ROUTINES
  SCHEMATA
  SEQUENCES
  TABLE_CONSTRAINTS
  TABLE_PRIVILEGES
  TABLES
  VIEW_COLUMN_USAGE
  VIEW_TABLE_USAGE
  VIEWS
  all_columns
  all_objects
  all_parameters
  all_sql_modules
  all_views
  allocation_units
  assemblies
  assembly_files
  assembly_modules
  assembly_references
  assembly_types
  asymmetric_keys
  availability_databases_cluster
  availability_group_listener_ip_addresses
  availability_group_listeners
  availability_groups
  availability_groups_cluster
  availability_read_only_routing_lists
  availability_replicas
  backup_devices
  certificates
  change_tracking_databases
  change_tracking_tables
  check_constraints
  column_encryption_key_values
  column_encryption_keys
  column_master_keys
  column_store_dictionaries
  column_store_row_groups
  column_store_segments
  column_type_usages
  column_xml_schema_collection_usages
  columns
  computed_columns
  configurations
  conversation_endpoints
  conversation_groups
  conversation_priorities
  credentials
  crypt_properties
  cryptographic_providers
  data_spaces
  database_audit_specification_details
  database_audit_specifications
  database_credentials
  database_files
  database_filestream_options
  database_mirroring
  database_mirroring_endpoints
  database_mirroring_witnesses
  database_permissions
  database_principals
  database_query_store_options
  database_recovery_status
  database_role_members
  database_scoped_configurations
  database_scoped_credentials
  databases
  default_constraints
  destination_data_spaces
  dm_audit_actions
  dm_audit_class_type_map
  dm_broker_activated_tasks
  dm_broker_connections
  dm_broker_forwarded_messages
  dm_broker_queue_monitors
  dm_cdc_errors
  dm_cdc_log_scan_sessions
  dm_clr_appdomains
  dm_clr_loaded_assemblies
  dm_clr_properties
  dm_clr_tasks
  dm_column_store_object_pool
  dm_cryptographic_provider_properties
  dm_database_encryption_keys
  dm_db_column_store_row_group_operational_stats
  dm_db_column_store_row_group_physical_stats
  dm_db_file_space_usage
  dm_db_fts_index_physical_stats
  dm_db_index_usage_stats
  dm_db_log_space_usage
  dm_db_mirroring_auto_page_repair
  dm_db_mirroring_connections
  dm_db_mirroring_past_actions
  dm_db_missing_index_details
  dm_db_missing_index_group_stats
  dm_db_missing_index_groups
  dm_db_partition_stats
  dm_db_persisted_sku_features
  dm_db_rda_migration_status
  dm_db_rda_schema_update_status
  dm_db_script_level
  dm_db_session_space_usage
  dm_db_task_space_usage
  dm_db_uncontained_entities
  dm_db_xtp_checkpoint_files
  dm_db_xtp_checkpoint_stats
  dm_db_xtp_gc_cycle_stats
  dm_db_xtp_hash_index_stats
  dm_db_xtp_index_stats
  dm_db_xtp_memory_consumers
  dm_db_xtp_nonclustered_index_stats
  dm_db_xtp_object_stats
  dm_db_xtp_table_memory_stats
  dm_db_xtp_transactions
  dm_exec_background_job_queue
  dm_exec_background_job_queue_stats
  dm_exec_cached_plans
  dm_exec_compute_node_errors
  dm_exec_compute_node_status
  dm_exec_compute_nodes
  dm_exec_connections
  dm_exec_distributed_request_steps
  dm_exec_distributed_requests
  dm_exec_distributed_sql_requests
  dm_exec_dms_services
  dm_exec_dms_workers
  dm_exec_external_operations
  dm_exec_external_work
  dm_exec_function_stats
  dm_exec_procedure_stats
  dm_exec_query_memory_grants
  dm_exec_query_optimizer_info
  dm_exec_query_optimizer_memory_gateways
  dm_exec_query_parallel_workers
  dm_exec_query_profiles
  dm_exec_query_resource_semaphores
  dm_exec_query_stats
  dm_exec_query_transformation_stats
  dm_exec_requests
  dm_exec_session_wait_stats
  dm_exec_sessions
  dm_exec_trigger_stats
  dm_exec_valid_use_hints
  dm_external_script_execution_stats
  dm_external_script_requests
  dm_filestream_file_io_handles
  dm_filestream_file_io_requests
  dm_filestream_non_transacted_handles
  dm_fts_active_catalogs
  dm_fts_fdhosts
  dm_fts_index_population
  dm_fts_memory_buffers
  dm_fts_memory_pools
  dm_fts_outstanding_batches
  dm_fts_population_ranges
  dm_fts_semantic_similarity_population
  dm_hadr_auto_page_repair
  dm_hadr_automatic_seeding
  dm_hadr_availability_group_states
  dm_hadr_availability_replica_cluster_nodes
  dm_hadr_availability_replica_cluster_states
  dm_hadr_availability_replica_states
  dm_hadr_cluster
  dm_hadr_cluster_members
  dm_hadr_cluster_networks
  dm_hadr_database_replica_cluster_states
  dm_hadr_database_replica_states
  dm_hadr_instance_node_map
  dm_hadr_name_id_map
  dm_hadr_physical_seeding_stats
  dm_io_backup_tapes
  dm_io_cluster_shared_drives
  dm_io_cluster_valid_path_names
  dm_io_pending_io_requests
  dm_logpool_hashentries
  dm_logpool_stats
  dm_os_buffer_descriptors
  dm_os_buffer_pool_extension_configuration
  dm_os_child_instances
  dm_os_cluster_nodes
  dm_os_cluster_properties
  dm_os_dispatcher_pools
  dm_os_dispatchers
  dm_os_hosts
  dm_os_latch_stats
  dm_os_loaded_modules
  dm_os_memory_allocations
  dm_os_memory_broker_clerks
  dm_os_memory_brokers
  dm_os_memory_cache_clock_hands
  dm_os_memory_cache_counters
  dm_os_memory_cache_entries
  dm_os_memory_cache_hash_tables
  dm_os_memory_clerks
  dm_os_memory_node_access_stats
  dm_os_memory_nodes
  dm_os_memory_objects
  dm_os_memory_pools
  dm_os_nodes
  dm_os_performance_counters
  dm_os_process_memory
  dm_os_ring_buffers
  dm_os_schedulers
  dm_os_server_diagnostics_log_configurations
  dm_os_spinlock_stats
  dm_os_stacks
  dm_os_sublatches
  dm_os_sys_info
  dm_os_sys_memory
  dm_os_tasks
  dm_os_threads
  dm_os_virtual_address_dump
  dm_os_wait_stats
  dm_os_waiting_tasks
  dm_os_windows_info
  dm_os_worker_local_storage
  dm_os_workers
  dm_qn_subscriptions
  dm_repl_articles
  dm_repl_schemas
  dm_repl_tranhash
  dm_repl_traninfo
  dm_resource_governor_configuration
  dm_resource_governor_external_resource_pool_affinity
  dm_resource_governor_external_resource_pools
  dm_resource_governor_resource_pool_affinity
  dm_resource_governor_resource_pool_volumes
  dm_resource_governor_resource_pools
  dm_resource_governor_workload_groups
  dm_server_audit_status
  dm_server_memory_dumps
  dm_server_registry
  dm_server_services
  dm_tcp_listener_states
  dm_tran_active_snapshot_database_transactions
  dm_tran_active_transactions
  dm_tran_commit_table
  dm_tran_current_snapshot
  dm_tran_current_transaction
  dm_tran_database_transactions
  dm_tran_global_recovery_transactions
  dm_tran_global_transactions
  dm_tran_global_transactions_enlistments
  dm_tran_global_transactions_log
  dm_tran_locks
  dm_tran_session_transactions
  dm_tran_top_version_generators
  dm_tran_transactions_snapshot
  dm_tran_version_store
  dm_xe_map_values
  dm_xe_object_columns
  dm_xe_objects
  dm_xe_packages
  dm_xe_session_event_actions
  dm_xe_session_events
  dm_xe_session_object_columns
  dm_xe_session_targets
  dm_xe_sessions
  dm_xtp_gc_queue_stats
  dm_xtp_gc_stats
  dm_xtp_system_memory_consumers
  dm_xtp_threads
  dm_xtp_transaction_recent_rows
  dm_xtp_transaction_stats
  endpoint_webmethods
  endpoints
  event_notification_event_types
  event_notifications
  events
  extended_procedures
  extended_properties
  external_data_sources
  external_file_formats
  external_tables
  filegroups
  filetable_system_defined_objects
  filetables
  foreign_key_columns
  foreign_keys
  fulltext_catalogs
  fulltext_document_types
  fulltext_index_catalog_usages
  fulltext_index_columns
  fulltext_index_fragments
  fulltext_indexes
  fulltext_languages
  fulltext_semantic_language_statistics_database
  fulltext_semantic_languages
  fulltext_stoplists
  fulltext_stopwords
  fulltext_system_stopwords
  function_order_columns
  hash_indexes
  http_endpoints
  identity_columns
  index_columns
  indexes
  internal_partitions
  internal_tables
  key_constraints
  key_encryptions
  linked_logins
  login_token
  masked_columns
  master_files
  master_key_passwords
  memory_optimized_tables_internal_attributes
  message_type_xml_schema_collection_usages
  messages
  module_assembly_usages
  numbered_procedure_parameters
  numbered_procedures
  objects
  openkeys
  parameter_type_usages
  parameter_xml_schema_collection_usages
  parameters
  partition_functions
  partition_parameters
  partition_range_values
  partition_schemes
  partitions
  periods
  plan_guides
  procedures
  query_context_settings
  query_store_plan
  query_store_query
  query_store_query_text
  query_store_runtime_stats
  query_store_runtime_stats_interval
  registered_search_properties
  registered_search_property_lists
  remote_data_archive_databases
  remote_data_archive_tables
  remote_logins
  remote_service_bindings
  resource_governor_configuration
  resource_governor_external_resource_pool_affinity
  resource_governor_external_resource_pools
  resource_governor_resource_pool_affinity
  resource_governor_resource_pools
  resource_governor_workload_groups
  routes
  schemas
  securable_classes
  security_policies
  security_predicates
  selective_xml_index_namespaces
  selective_xml_index_paths
  sequences
  server_assembly_modules
  server_audit_specification_details
  server_audit_specifications
  server_audits
  server_event_notifications
  server_event_session_actions
  server_event_session_events
  server_event_session_fields
  server_event_session_targets
  server_event_sessions
  server_events
  server_file_audits
  server_permissions
  server_principal_credentials
  server_principals
  server_role_members
  server_sql_modules
  server_trigger_events
  server_triggers
  servers
  service_broker_endpoints
  service_contract_message_usages
  service_contract_usages
  service_contracts
  service_message_types
  service_queue_usages
  service_queues
  services
  soap_endpoints
  spatial_index_tessellations
  spatial_indexes
  spatial_reference_systems
  sql_dependencies
  sql_expression_dependencies
  sql_logins
  sql_modules
  stats
  stats_columns
  symmetric_keys
  synonyms
  sysaltfiles
  syscacheobjects
  syscharsets
  syscolumns
  syscomments
  sysconfigures
  sysconstraints
  syscurconfigs
  syscursorcolumns
  syscursorrefs
  syscursors
  syscursortables
  sysdatabases
  sysdepends
  sysdevices
  sysfilegroups
  sysfiles
  sysforeignkeys
  sysfulltextcatalogs
  sysindexes
  sysindexkeys
  syslanguages
  syslockinfo
  syslogins
  sysmembers
  sysmessages
  sysobjects
  sysoledbusers
  sysopentapes
  sysperfinfo
  syspermissions
  sysprocesses
  sysprotects
  sysreferences
  sysremotelogins
  sysservers
  system_columns
  system_components_surface_area_configuration
  system_internals_allocation_units
  system_internals_partition_columns
  system_internals_partitions
  system_objects
  system_parameters
  system_sql_modules
  system_views
  systypes
  sysusers
  table_types
  tables
  tcp_endpoints
  time_zone_info
  trace_categories
  trace_columns
  trace_event_bindings
  trace_events
  trace_subclass_values
  traces
  transmission_queue
  trigger_event_types
  trigger_events
  triggers
  type_assembly_usages
  types
  user_token
  via_endpoints
  views
  xml_indexes
  xml_schema_attributes
  xml_schema_collections
  xml_schema_component_placements
  xml_schema_components
  xml_schema_elements
  xml_schema_facets
  xml_schema_model_groups
  xml_schema_namespaces
  xml_schema_types
  xml_schema_wildcard_namespaces
  xml_schema_wildcards
  -----Schemas-----
  db_accessadmin, null
  db_backupoperator, null
  db_datareader, null
  db_datawriter, null
  db_ddladmin, null
  db_denydatareader, null
  db_denydatawriter, null
  db_owner, null
  db_securityadmin, null
  dbo, null
  guest, null
  INFORMATION_SCHEMA, null
  sys, null
  </code></pre>
  
  <p>The Schema dbo is in there, but none of my tables seem to be in the list. Here are a few SSMS screenshots:</p>
  
  <p><a href="https://i.stack.imgur.com/Lyi2H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lyi2H.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/fChxb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fChxb.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/kMq7m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kMq7m.png" alt="enter image description here"></a></p>
  
  <p>If anyone can help me solve the problems, it would be great!</p>
  
  <p><strong>--edit--</strong>
  In SQL server configuration manager I have the following error;
  <a href="https://i.stack.imgur.com/85TLP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/85TLP.png" alt="enter image description here"></a></p>